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/53465] New: [4.7 regression] wrong code with -O1 -ftree-vrp


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

             Bug #: 53465
           Summary: [4.7 regression] wrong code with -O1 -ftree-vrp
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: luto@mit.edu


This code aborts with -O1 -ftree-vrp.  It shouldn't.  gcc 4.6 is okay;
4_7-branch from today and trunk are both bad.

extern void abort();

static const char input[] = {1,2};

void test(char const *data, int len)
{
  int i;
  int found_x = 0;
  char prev_x;
  for(i = 0; i < len; i++) {
    char x = data[i];

    if (x == 0)
      break;

    if (found_x && x <= prev_x)
      abort();

    prev_x = x;
    found_x = 1;
  }
}

int main()
{
  test(input, 2);
  return 1;
}

Changing char x to volatile char x or initializing prev_x before the loop will
prevent the crash.


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