From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 549B63858D35; Mon, 7 Mar 2022 12:39:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 549B63858D35 From: "rverschelde at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104789] [12 Regression] New -Wstringop-overflow false positive since r12-5863-g9354a7d70caef1c9 Date: Mon, 07 Mar 2022 12:39:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: rverschelde at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Mon, 07 Mar 2022 12:39:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104789 --- Comment #6 from R=C3=A9mi Verschelde --- Indeed if the warning was reworded to make it clear that it's a risk and no= t a certainty would solve this. Both the reduced test case and the original code are both risky: `component= s` is an `uint32_t` that is set to either 1 or 3, so in the context of that co= de `header_bytes` would never exceed 8. But if this was changed to anything higher than 3 then yes, there would be a buffer overflow. If this is what this warning aims to warn about (the risk = of buffer overflow and not the certainty of one), then there's probably no fal= se positive. Adding: ``` if (components > 3) { return 0; } ``` to the reduced testcase does prevent the warning. On the other hand, the same kind of check doesn't seem to solve the warning= in the original Godot case, so you're right about the reduced testcase being t= oo reduced. I'll dig further and see if I can make a better testcase, or understand why a check on `components` (or even `header_bytes > 7`) isn't sufficient in Godot.=