From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E9E793856DD6; Thu, 28 Apr 2022 13:21:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9E793856DD6 From: "byteslice at airmail dot cc" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105420] New: Bogus -Warray-bounds with non-compile time-constant variable Date: Thu, 28 Apr 2022 13:21:43 +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: byteslice at airmail dot cc 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 target_milestone attachments.created 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: Thu, 28 Apr 2022 13:21:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105420 Bug ID: 105420 Summary: Bogus -Warray-bounds with non-compile time-constant variable Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: byteslice at airmail dot cc Target Milestone: --- Created attachment 52894 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52894&action=3Dedit Reduced example On gcc 12.0.1 20220413 (Fedora 36 Beta), with c++ -O1 -fexpensive-optimizat= ions -ftree-vrp -Werror=3Darray-bounds, the attachment fails to compile, with the following message: : In function 'void Initialize(int)': :9:53: error: array subscript -1 is below array bounds of 'int [8]' [-Werror=3Darray-bounds] 9 | int phys_core =3D VirtualToPhysicalCoreMap[virt_core]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ :2:5: note: while referencing 'VirtualToPhysicalCoreMap' 2 | int VirtualToPhysicalCoreMap[8]; | ^~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: some warnings being treated as errors Compiler returned: 1 virt_core does not have a compile time-constant evaluation, so this warning= is bogus. The bogus warning does not appear in older versions of GCC. Removing either -fexpensive-optimizations or -ftree-vrp allows compilation = to succeed.=