This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/53465] New: [4.7 regression] wrong code with -O1 -ftree-vrp
- From: "luto at mit dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 May 2012 00:44:43 +0000
- Subject: [Bug tree-optimization/53465] New: [4.7 regression] wrong code with -O1 -ftree-vrp
- Auto-submitted: auto-generated
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.