[Bug middle-end/98548] missing warning on strcmp with a nonstring member

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Dec 11 07:40:06 GMT 2021


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection
      Known to fail|                            |11.2.0
      Known to work|                            |12.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks fixed on the trunk:
<source>: In function 'f':
<source>:11:15: warning: '__builtin_strcmp' argument 1 declared attribute
'nonstring' is smaller than the specified bound 8 [-Wstringop-overread]
   11 |   return 0 == __builtin_strcmp (a.a, a.b);   // warning (good)
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:8: note: argument 'a' declared here
    4 |   char a[4] __attribute__ ((nonstring));
      |        ^
<source>: In function 'g':
<source>:16:15: warning: '__builtin_strcmp' argument 1 declared attribute
'nonstring' is smaller than the specified bound 8 [-Wstringop-overread]
   16 |   return 0 == __builtin_strcmp (p->a, p->b);   // missing warning
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:8: note: argument 'a' declared here
    4 |   char a[4] __attribute__ ((nonstring));
      |        ^


More information about the Gcc-bugs mailing list