public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-89800-4-oh55C1P2Wk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-89800-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89800

Martin Sebor <msebor at gcc dot gnu.org> 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 gnu.org
         Resolution|---                         |FIXED

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 12 prints the full inlining stack for the test case in comment #0 (thanks
to r12-1992 and related):

In function ‘T foo(T, int) [with T = int]’,
    inlined from ‘int bar(int)’ at pr89800.C:10:28,
    inlined from ‘int main()’ 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_algobase.h:66,
                 from
/build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/array:43,
                 from pr89800-2.C:1:
In function ‘constexpr void std::__advance(_InputIterator&, _Distance,
std::input_iterator_tag) [with _InputIterator =
std::_Fwd_list_const_iterator<int>; _Distance = long int]’,
    inlined from ‘constexpr void std::advance(_InputIterator&, _Distance) [with
_InputIterator = std::_Fwd_list_const_iterator<int>; _Distance = long int]’ at
/build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:207:21,
    inlined from ‘constexpr _BidirectionalIterator
std::prev(_BidirectionalIterator, typename
std::iterator_traits<_Iter>::difference_type) [with _BidirectionalIterator =
std::_Fwd_list_const_iterator<int>]’ at
/build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:233:19,
    inlined from ‘typename T::value_type back(const T&) [with T =
std::forward_list<int>]’ at pr89800-2.C:9:20:
/build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_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_iterator_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.)

           reply	other threads:[~2021-09-01 18:19 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <bug-89800-4@http.gcc.gnu.org/bugzilla/>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-89800-4-oh55C1P2Wk@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).