https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115702
Bug ID: 115702 Summary: Incorrect stringop-overflow warning with -O3 Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: christian at zeek dot org Target Milestone: --- When compiling sqlite's all-in-one source file with -O3 it throws an erroneous stringop-overread warning not present with -O2: $ wget https://www.sqlite.org/2024/sqlite-amalgamation-3460000.zip $ md5sum sqlite-amalgamation-3460000.zip 78c40a42c3d2e2a52ab011edb33e99cf sqlite-amalgamation-3460000.zip $ unzip sqlite-amalgamation-3460000.zip $ cd sqlite-amalgamation-3460000 $ gcc -c -Wall -O3 sqlite3.c In function ‘sqlite3Strlen30’, inlined from ‘sqlite3ColumnSetColl’ at sqlite3.c:122170:10: sqlite3.c:35009:28: error: ‘strlen’ reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 35009 | return 0x3fffffff & (int)strlen(z); | ^~~~~~~~~ In function ‘sqlite3ColumnSetColl’: cc1: note: source object is likely at address zero $ $ gcc -c -Wall -O2 sqlite3.c $ Apologies for not reducing this to a manageable reproducer. I am not affiliated with the sqlite3 project and just wanted to send a heads-up since we noticed this in our project, which embeds their source, and uses -Werror. I could only trigger this on sqlite's all-in-one source file, not the individual sources. Discussion in the sqlite3 project: https://www.sqlite.org/forum/forumpost/b1cc55671e Context on gcc: $ gcc --version gcc (GCC) 14.1.1 20240620 (Red Hat 14.1.1-6) $ rpm -qf /usr/bin/gcc gcc-14.1.1-6.fc40.x86_64 $ lsb_release -a LSB Version: :core-5.0-amd64:core-5.0-noarch Distributor ID: Fedora Description: Fedora release 40 (Forty) $ uname -a Linux test 6.9.5-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jun 16 15:47:09 UTC 2024 x86_64 GNU/Linux Best, Christian