https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108074
Bug ID: 108074 Summary: Incorrect stringop-overflow warning Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alastair.j.irving at gmail dot com Target Milestone: --- Created attachment 54071 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54071&action=edit Reproducer Compiling with -O2 or higher I get an incorrect warning: test.c: In function ‘foo3’: test.c:15:5: warning: ‘foo’ accessing 16 bytes in a region of size 8 [-Wstringop-overflow=] This doesn't appear at lower optimization levels. It's also very sensative to the function, for example removing the return on the next line makes the warning go away.