public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/57199] [4.8/4.9 Regression] Bogus warning: iteration NNNN invokes undefined behavior -Waggressive-loop-optimizations
Date: Wed, 08 May 2013 08:58:00 -0000	[thread overview]
Message-ID: <bug-57199-4-tN1bNav5DQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-57199-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57199

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2013-05-08 08:57:45 UTC ---
Note that there seems to be an error in the source:

    void resize(size_t n) {
        size_t s = size();
        DestroyElements(mutable_array() + n, s - n);

for the call with n == size () + 1 the function calls DestroyElements
with -1U elements which we figure out and optimize the caller to

  <bb 3>:
  _13 = i_12 * 80;
  _14 = _11 + _13;
  Foo::~Foo (_14);
  i_15 = i_12 + 1;

  <bb 4>:
  # i_12 = PHI <0(2), i_15(3)>
  if (i_12 != 18446744073709551615)
    goto <bb 3>;
  else
    goto <bb 5>;

which then causes the addition to overflow and invoke undefined behavior
and we warn.

Thus, the warning, while not 100% helpful, points at a real problem.


  parent reply	other threads:[~2013-05-08  8:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-07 22:09 [Bug c++/57199] New: [4.8, 4.9] " ppluzhnikov at google dot com
2013-05-07 23:01 ` [Bug c++/57199] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
2013-05-08  8:58 ` rguenth at gcc dot gnu.org [this message]
2013-05-08 12:55 ` [Bug tree-optimization/57199] " ppluzhnikov at google dot com
2013-05-15 13:29 ` rguenth at gcc dot gnu.org
2013-05-20  8:12 ` jakub at gcc dot gnu.org
2013-05-20 14:10 ` ppluzhnikov at google dot com
2013-05-20 14:26 ` jakub at gcc dot gnu.org
2013-05-20 15:19 ` ppluzhnikov at google dot com
2014-03-26 20:39 ` dichlofos-mv at yandex dot ru
2014-03-26 20:56 ` ppluzhnikov at google dot com

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-57199-4-tN1bNav5DQ@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).