[Bug middle-end/98465] Bogus warning stringop-overread wuth -std=gnu++20 -O2 and std::string::insert

romain.geissler at amadeus dot com gcc-bugzilla@gcc.gnu.org
Wed Dec 30 12:49:46 GMT 2020


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

--- Comment #2 from Romain Geissler <romain.geissler at amadeus dot com> ---
Hi Martin,

Thanks for your investigation.

I have a few questions:
 - Since the warning seems to be fully emitted by system headers, shouldn't it
be silenced by default ? Why isn't it the case here ? On compiler explorer,
"x86-64 gcc 10.2" and flags "-std=gnu++20 -O2" I get no warning, yet with flags
"-std=gnu++20 -O2 -Wsystem-headers" I get a -Wstringop-overflow warning about
the same problem. Meaning that for stringop-overflow system headers seems to be
taken into account, but not for stringop-overread, is that expected ?
 - I understood why you did not reproduce the bug with gcc 11, my test case,
and flags "-std=gnu++20 -O2". It looks like Compiler explorer forces "-g" by
default. And it seems debug output generation does affect the warning. With
flags "-std=gnu++20 -O2 -g0" (effectively disable debug information generation)
I get no warning, while with "-std=gnu++20 -O2 -g" I get the stringop-overread
warning. Again, gcc 10 doesn't seem to be impacted by debug output generation
to trigger this warning, is this expected ?

There seems to be a strange interaction between -Wsystem-headers and -g in gcc
11 which I don't understand. See the following matrix:
 - "-std=gnu++20 -O2 -Wno-system-headers -g0" --> no warning
 - "-std=gnu++20 -O2 -Wno-system-headers -g"  --> warning
 - "-std=gnu++20 -O2 -Wsystem-headers -g0"    --> warning
 - "-std=gnu++20 -O2 -Wsystem-headers -g"     --> warning

(this last matrix was tested on compiler explorer).

I am confused.

Cheers,
Romain


More information about the Gcc-bugs mailing list