From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 96C6F3858D39; Fri, 4 Mar 2022 16:26:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 96C6F3858D39 From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104789] New: [12 Regression] New -Wstringop-overflow false positive since r12-5863-g9354a7d70caef1c9 Date: Fri, 04 Mar 2022 16:26:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2022 16:26:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104789 Bug ID: 104789 Summary: [12 Regression] New -Wstringop-overflow false positive since r12-5863-g9354a7d70caef1c9 Product: gcc Version: 12.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: msebor at gcc dot gnu.org Target Milestone: --- It's originally reported here: https://github.com/godotengine/godot/issues/58747 $ cat godot-stringop.cpp #include #include uint32_t some_func(const uint32_t components) { uint8_t header[8]; uint32_t header_bytes =3D 0; for (uint32_t i =3D 0; i < components; i++) { header_bytes +=3D 2; } header_bytes +=3D 2; // This works it around, but shouldn't be needed AFAICT. //while (header_bytes !=3D 8 && header_bytes % 4 !=3D 0) { while (header_bytes % 4 !=3D 0) { header[header_bytes++] =3D 0; } for (uint32_t i =3D 0; i < header_bytes; i++) { printf("%d\n", header[i]); } return header_bytes; } int main() { some_func(1); some_func(3); return 0; } $ g++ godot-stringop.cpp -c -Werror=3Dall -O3 godot-stringop.cpp: In function =E2=80=98uint32_t some_func(uint32_t)=E2=80= =99: godot-stringop.cpp:14:40: error: writing 1 byte into a region of size 0 [-Werror=3Dstringop-overflow=3D] 14 | header[header_bytes++] =3D 0; | ~~~~~~~~~~~~~~~~~~~~~~~^~~ godot-stringop.cpp:5:17: note: at offset 8 into destination object =E2=80= =98header=E2=80=99 of size 8 5 | uint8_t header[8]; | ^~~~~~ cc1plus: some warnings being treated as errors=