https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77622
Sam James <sjames at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sjames at gcc dot gnu.org Keywords| |needs-bisection --- Comment #4 from Sam James <sjames at gcc dot gnu.org> --- The testcase works for me with 10..15. $ gcc a.c -O2 -o a -U_FORTIFY_SOURCE && ./a a.c: In function ‘main’: a.c:3:3: warning: ‘__builtin___memcpy_chk’ writing 5 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] 3 | __builtin___memcpy_chk (dest, src, n, bos (dest)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.c:23:5: note: in expansion of macro ‘memcpy’ 23 | memcpy (p, "abcdef", 5); | ^~~~~~ a.c:3:3: warning: ‘__builtin___memcpy_chk’ writing 5 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] 3 | __builtin___memcpy_chk (dest, src, n, bos (dest)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.c:33:5: note: in expansion of macro ‘memcpy’ 33 | memcpy (p, "abcdef", 5); | ^~~~~~ 0 0 0 0 *** buffer overflow detected ***: terminated Aborted (core dumped) ./a