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: unassig...@gcc.gnu.org ReportedBy: l...@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.