https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83373

--- Comment #4 from Daniel Fruzynski <bugzi...@poradnik-webmastera.com> ---
> Bug 83373 - False positive reported by -Wstringop-overflow, is
> another example of warning triggered by a missed optimization
> opportunity, this time in the strlen pass.  The optimization
> is discussed in pr78450 - strlen(s) return value can be assumed
> to be less than the size of s.  The gist of it is that the result
> of strlen(array) can be assumed to be less than the size of
> the array (except in the corner case of last struct members).

This approach is not good from my perspective. I have structs used for IPC
purposes, and I cannot reorder fields or add a new one at the end to silence
this warning. Better approach would be to explicitly mark structure as flexible
width with special attribute, and use this approach only for structures marked
this way. As you wrote, this is a corner case, so requiring this attribute
there can be accepted. This can also improve diagnostics in other cases, if you
use similar approach for other warnings too.

Reply via email to