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

           Summary: [4.6 Regression] -Wstrict-overflow warning on code
                    that doesn't have overflows
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ja...@gcc.gnu.org


int
foo (const char *x)
{
  unsigned long l = 1;
  const unsigned char *s = (const unsigned char *) (const char *) (x);
  int r = s[0] - ((const unsigned char *) (const char *) ("/"))[0];
  if (l > 0 && r == 0)
    r = (s[1] - ((const unsigned char *) (const char *) ("/"))[1]);
  return r;
}

gets at -O2 on x86_64-linux
warning: assuming signed overflow does not occur when changing X +- C1 cmp C2
to X cmp C1 +- C2 [-Wstrict-overflow]

This is simplified return strcmp (path, "/"); when using glibc <string.h>
strcmp macro.

The warning started with
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161655

Reply via email to