[Bug middle-end/101134] Bogus -Wstringop-overflow warning about non-existent overflow

dangelog at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 21 16:44:48 GMT 2021


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

--- Comment #2 from Giuseppe D'Angelo <dangelog at gmail dot com> ---
As I said,

> Adding enough __builtin_unreachable() for that condition removes the warnings, but it should not be necessary.

I disagree with the resolution, though. While I understand that GCC cannot
reason globally, the warning message itself is miselading, as it's worded in a
way that makes the user think that GCC has *conclusevely* proven the existence
of a problem, while in fact GCC is wrong. Specifically, this statement:

>     <source>:75:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

At least, I'd like a less strong wording if GCC cannot *prove* this but only
estimate it (e.g. "warning: possible string overflow (writing 1 byte...)").
Ideally, even, having two separate warnings or two separate warning levels
(overflow proved / overflow just estimated) so one can enable only one of the
two if needed.


More information about the Gcc-bugs mailing list