https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107038
Bug ID: 107038 Summary: [13 Regression] Bogus -Wstringop-overflow= since r13-2789-gb40b3035879cf695 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: amacleod at redhat dot com, msebor at gcc dot gnu.org Target Milestone: --- Created attachment 53627 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53627&action=edit Original unreduced test-case Reduced from elfutils: $ cat core-file.c #include <unistd.h> struct ar_hdr { char ar_mode[8]; char ar_size[10]; }; int r; struct Elf { int fildes; } pread_retry(int fd, void *buf, size_t len, off_t offset) { ssize_t recvd; r = pread(fd, buf + recvd, len - recvd, offset); } void elf_begin_rand() { struct Elf *parent; struct ar_hdr h; pread_retry(parent->fildes, h.ar_size, sizeof(h.ar_size), 0); } $ gcc core-file.c -c -O2 -Werror=stringop-overflow -D_FORTIFY_SOURCE=3 In file included from /usr/include/features.h:490, from /usr/include/unistd.h:25, from core-file.c:1: In function ‘pread’, inlined from ‘pread_retry’ at core-file.c:13:7, inlined from ‘elf_begin_rand’ at core-file.c:19:3: /usr/include/bits/unistd.h:74:10: error: ‘__pread_alias’ writing 18 or more bytes into a region of size 10 overflows the destination [-Werror=stringop-overflow=] 74 | return __glibc_fortify (pread, __nbytes, sizeof (char), | ^~~~~~~~~~~~~~~ core-file.c: In function ‘elf_begin_rand’: core-file.c:4:8: note: destination object ‘ar_size’ of size 10 4 | char ar_size[10]; | ^~~~~~~ /usr/include/bits/unistd.h:50:16: note: in a call to function ‘__pread_alias’ declared with attribute ‘access (write_only, 2, 3)’ 50 | extern ssize_t __REDIRECT (__pread_alias, | ^~~~~~~~~~ cc1: some warnings being treated as errors I'm attaching also original unreduced test-case.