public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2011-11-29 22:57 burnus at gcc dot gnu.org
  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
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-29 22:57 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/51350] [4.7 Regression] Bogus -Wstrict-overflow warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
  2011-11-29 22:57 [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 burnus at gcc dot gnu.org
@ 2011-12-05 14:12 ` rguenth at gcc dot gnu.org
  2011-12-05 15:17 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-05 14:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/51350] [4.7 Regression] Bogus -Wstrict-overflow warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
  2011-11-29 22:57 [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 burnus at gcc dot gnu.org
  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
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-05 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-05 15:17:08 UTC ---
This is a valid warning.  We transform (in forwprop)

  int suffix = pattern_length + 1;
...
  if (suffix < pattern_length)

to

  if (0)

which is true only when pattern_length + 1 does not overflow.
This happens after jump-threading over

  while (i > start)
    suffix_table[--i] = --suffix;

in case i is <= start, thus the "regression" is probably because of
jump-threading improvements for 4.7.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-05 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 22:57 [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 burnus at gcc dot gnu.org
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

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).