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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
$ gcc-14 foo.cxx -Og -ggdb3 -o /tmp/a && /tmp/a
# nothing

$ gcc-15 foo.cxx -Og -ggdb3 -o /tmp/a && /tmp/a
In file included from /usr/include/string.h:548,
                 from
/usr/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/cstring:48,
                 from foo.cxx:3:
In function ‘char* strncpy(char*, const char*, size_t)’,
    inlined from ‘void gen_blr(const char*)’ at foo.cxx:21:22:
/usr/include/bits/string_fortified.h:100:34: warning: ‘char*
__builtin___strncpy_chk(char*, const char*, long unsigned int, long unsigned
int)’ writing 3 bytes into a region of size 0 overflows the destination
[-Wstringop-overflow=]
  100 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
  101 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
*** buffer overflow detected ***: terminated
Aborted                    (core dumped) /tmp/a

Reply via email to