This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/83373] False positive reported by -Wstringop-overflow
- From: "bugzilla at poradnik-webmastera dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Dec 2017 06:59:03 +0000
- Subject: [Bug middle-end/83373] False positive reported by -Wstringop-overflow
- Auto-submitted: auto-generated
- References: <bug-83373-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83373
--- Comment #4 from Daniel Fruzynski <bugzilla@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.