From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C02643858C2D; Tue, 8 Feb 2022 21:07:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C02643858C2D From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort() Date: Tue, 08 Feb 2022 21:07:07 +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, missed-optimization 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: bug_file_loc keywords 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: Tue, 08 Feb 2022 21:07:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104165 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://bugzilla.redhat.com | |/show_bug.cgi?id=3D2051783 Keywords| |missed-optimization --- Comment #2 from Martin Sebor --- See also another similar test case reduced in https://bugzilla.redhat.com/show_bug.cgi?id=3D2051783: #include bool cond; int foo; int func (void) { int a[3], qa =3D 0; for(int i =3D 0; i < 3; i++) if (cond) a[qa++] =3D foo; std::sort (a, a + qa); return 0; } The warning is issued for the synthesized call to std::__insertion_sort.isr= a() in basic block 9 (vrp1 output): [local count: 71766220]: std::__insertion_sort.isra (&a, &MEM [(void *)&a + 64B]); <<< -Warray-bounds goto ; [100.00%] The block is unreachable but GCC is unable to determine that from the loop.= =20 Adding an annotation just after the loop asserting that avoids the warning = and also improves the emitted object code. The same warning triggers in GCC 11 with -Wsystem-headers. The difference = in GCC 12 is that -Wsystem-headers no longer disables warnings for code define= d in system headers that's inlined into user code.=