From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AA22F385AC20; Wed, 1 Dec 2021 16:38:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA22F385AC20 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103483] context-sensitive ranges change triggers stringop-overread Date: Wed, 01 Dec 2021 16:38:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WONTFIX 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: cc 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: Wed, 01 Dec 2021 16:38:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103483 Aldy Hernandez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at gcc dot gnu.org, | |amacleod at redhat dot com, | |jwakely.gcc at gmail dot c= om --- Comment #6 from Aldy Hernandez --- (In reply to Martin Sebor from comment #4) > I don't think this can be "fixed." Most middle end warnings work a single > statement at a time and depend on optimization like constant propagation = and > dead code elimination to do their job. If one optimization exposes an > invalid statement that would otherwise be eliminated by another optimizat= ion > that doesn't take place, the warnings trigger. That's all by design and > there's no way change that. In the test case in comment #0 where the > precondition is that d be less than a, making it explicit (e.g., either as > Andrew suggests in comment #1 or by adding an equivalen assert statement) > seems like the best and only solution. Oh, it totally could be fixed. Whether you want to or not, is a separate issue. These false positives "by design" arguments are just a cop-out. As Jonathan said, if the warning code can't handle the IL as presented, it should give up, not assume code is wrong by default. It seems we do very bad with a lot of these warnings at -O1. We should just disable them at low optimization levels if we can't/won't take measures to reduce the false positive rate here.=