From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9C12D3858D28; Fri, 29 Apr 2022 06:26:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C12D3858D28 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105420] Bogus -Warray-bounds with non-compile time-constant variable Date: Fri, 29 Apr 2022 06:26:16 +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 X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed keywords blocked cf_reconfirmed_on bug_status 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: Fri, 29 Apr 2022 06:26:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105420 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Keywords| |diagnostic Blocks| |56456 Last reconfirmed| |2022-04-29 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener --- GCC threads the Initialize_type check and effectively sees if (Initialize_type) { if (virt_core >=3D 0) return; int phys_core =3D VirtualToPhysicalCoreMap[virt_core]; // virt_core is negative if (phys_core) external(); } else { int phys_core =3D VirtualToPhysicalCoreMap[virt_core]; if (phys_core && Initialize_type =3D=3D Kernel) external(); } it should probably warn that virt_core is negative, not that it is literall= y -1 here. I agree the diagnostic can be improved, but telling the user the execution path considered is probably difficult (at best we might somehow be able to emit a maybe warning). Still there's an obvious defect in your program that's worth fixing, possib= ly by refactoring of this code. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds=