From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8D366385AC25; Wed, 1 Sep 2021 18:19:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D366385AC25 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/89800] -Waggressive-loop-optimization warning doesn't have useful location Date: Wed, 01 Sep 2021 18:19:00 +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: 9.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc bug_status target_milestone cf_known_to_fail component assigned_to resolution 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 Sep 2021 18:19:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D89800 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Status|NEW |RESOLVED Target Milestone|--- |12.0 Known to fail| |10.2.0, 11.2.0, 8.3.0, | |9.2.0 Component|tree-optimization |middle-end Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot g= nu.org Resolution|--- |FIXED --- Comment #2 from Martin Sebor --- GCC 12 prints the full inlining stack for the test case in comment #0 (than= ks to r12-1992 and related): In function =E2=80=98T foo(T, int) [with T =3D int]=E2=80=99, inlined from =E2=80=98int bar(int)=E2=80=99 at pr89800.C:10:28, inlined from =E2=80=98int main()=E2=80=99 at pr89800.C:14:13: pr89800.C:5:3: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations] 5 | while (n--) | ^~~~~ pr89800.C:5:3: note: within this loop Similarly, for the bigger test case GCC prints the following output (-Wno-system-headers is no longer necessary): In file included from /build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobas= e.h:66, from /build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/array:43, from pr89800-2.C:1: In function =E2=80=98constexpr void std::__advance(_InputIterator&, _Distan= ce, std::input_iterator_tag) [with _InputIterator =3D std::_Fwd_list_const_iterator; _Distance =3D long int]=E2=80=99, inlined from =E2=80=98constexpr void std::advance(_InputIterator&, _Dis= tance) [with _InputIterator =3D std::_Fwd_list_const_iterator; _Distance =3D long i= nt]=E2=80=99 at /build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterato= r_base_funcs.h:207:21, inlined from =E2=80=98constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) [with _BidirectionalIterator = =3D std::_Fwd_list_const_iterator]=E2=80=99 at /build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterato= r_base_funcs.h:233:19, inlined from =E2=80=98typename T::value_type back(const T&) [with T =3D std::forward_list]=E2=80=99 at pr89800-2.C:9:20: /build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterato= r_base_funcs.h:153:7: warning: iteration 9223372036854775807 invokes undefined behavior [-Waggressive-loop-optimizations] 153 | while (__n--) | ^~~~~ /build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterato= r_base_funcs.h:153:7: note: within this loop With that I think we can resolve this as fixed. (The poor phrasing should = be handled separately. Please open a new bug for it.)=