From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 88F363861970; Thu, 12 Aug 2021 17:35:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88F363861970 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101830] [12 Regression] Incorrect error messages beginning with r12-2591 (backward jump threader) Date: Thu, 12 Aug 2021 17:35:04 +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: diagnostic, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org 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: Thu, 12 Aug 2021 17:35:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101830 --- Comment #6 from Martin Sebor --- I've only looked at the first warning so far. It's issued for the access i= n bb 8: [local count: 4057510040]: pos.80_31 =3D pos; if (pos.80_31 <=3D 1023) goto ; [96.34%] else goto ; [3.66%] [local count: 256307115]: # pos.80_21 =3D PHI _1 =3D linebuf[pos.80_21]; <<< -Warray-bounds ... The index is in the range [1024, INT_MAX] so the warning is correct given t= he IL. There isn't much I see that could be improved about the diagnostic exce= pt mentioning the range of the subscript rather than just its lower bound. Th= is instance of the warning or its phrasing also haven't changed in years. It's not the result of a recent enhancement or a questionable heuristic but simp= ly reflects a change in the IL, and it's always been phrased as "is out of bounds". No "may be out of bounds" form exists, never has, and adding one wouldn't help in this instance. That said, since pos is a global variable, the test in safe_inc_pos() that would otherwise constrain its value only has that effect in the absence of intervening statements that might overwrite it. You might get a better res= ult with a pair of "setter" and "getter" functions where the latter asserted the range via __builtin_unreachable() before returning the variable. Otherwise, the test is what likely is used by the backward threader to introduce the unreachable branch which isn't eliminated because GCC can't prove the varia= ble isn't incremented beyond its upper limit. (Aldy is in a much better positi= on to explain this.)=