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: unassig...@gcc.gnu.org
        ReportedBy: bur...@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 via email to