public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/51350] New: [4.7 Regression] Bogus -Wstrict-overflow warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
Date: Tue, 29 Nov 2011 22:57:00 -0000	[thread overview]
Message-ID: <bug-51350-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             Bug #: 51350
           Summary: [4.7 Regression] Bogus -Wstrict-overflow warning:
                    assuming signed overflow does not occur when assuming
                    that (X + c) < X is always false
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
              Host: x86_64-unknown-linux-gnu


When compiling the following code with g++ -Wall -O2 test.cc, one gets with GCC
4.7.0 20111129. [GCC 4.6.2 does not print a warning.]

test.cc:9:3: Warnung: assuming signed overflow does not occur when assuming
that (X + c) < X is always false [-Wstrict-overflow]

However, I fail to see why one has (X + c) < X for the general case; it should
only occur if (start >= pattern_length), but as the value for "start" is not
known at compile time ...


void PopulateBoyerMooreTable(int pattern_length, int start,
                             int * shift_table, int* suffix_table,
                             int length)
{
  int suffix = pattern_length + 1;
  int i = pattern_length;
  while (i > start)
    suffix_table[--i] = --suffix;
  if (suffix < pattern_length)
    for (int j = start; j <= pattern_length; j++)
      shift_table[j] = suffix - start;
}


Original file:
http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/string-search.h#150


             reply	other threads:[~2011-11-29 22:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29 22:57 burnus at gcc dot gnu.org [this message]
2011-12-05 14:12 ` [Bug c++/51350] " rguenth at gcc dot gnu.org
2011-12-05 15:17 ` rguenth at gcc dot gnu.org

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