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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sjames at gcc dot gnu.org

--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> The wording of the diagnostic is still misleading (but ISTR I added a note:
> indicating there might be a NULL pointer).

It doesn't seem to show up for -Warray-bounds, but also:

$ g++ a.cxx -O3 -c -Wall
In file included from /usr/include/string.h:580,
                 from
/usr/lib/gcc/x86_64-pc-linux-gnu/17/include/g++-v17/cstring:48,
                 from a.cxx:15:
In function ‘void* memset(void*, int, size_t)’,
    inlined from ‘void ClearAllThings(int)’ at a.cxx:29:11:
/usr/include/bits/string_fortified.h:59:33: warning: ‘void*
__builtin_memset(void*, int, long unsigned int)’ offset [0, 31] is out of the
bounds [0, 0] [-Warray-bounds=]
   59 |   return __builtin___memset_chk (__dest, __ch, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
   60 |                                  __glibc_objsize0 (__dest));

vs

$ g++ a.cxx -O3 -c
In file included from /usr/include/string.h:580,
                 from
/usr/lib/gcc/x86_64-pc-linux-gnu/17/include/g++-v17/cstring:48,
                 from a.cxx:15:
In function ‘void* memset(void*, int, size_t)’,
    inlined from ‘void ClearAllThings(int)’ at a.cxx:29:11:
/usr/include/bits/string_fortified.h:59:33: warning: ‘void*
__builtin_memset(void*, int, long unsigned int)’ writing 32 bytes into a region
of size 0 overflows the destination [-Wstringop-overflow=]
   59 |   return __builtin___memset_chk (__dest, __ch, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
   60 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘void ClearAllThings(int)’:
cc1plus: note: destination object is likely at address zero

.. is that expected? I don't think I've seen one warning affecting the other
before. Why does adding -Wall mean we don't get -Wstringop-overflow? Do we have
something to inhibit diagnosing the same statement twice?

Reply via email to