This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/48022] New: [4.6 Regression] -Wstrict-overflow warning on code that doesn't have overflows


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: unassigned@gcc.gnu.org
        ReportedBy: jakub@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]