http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58223
Bug ID: 58223
Summary: wrong code at -O3 on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The current gcc trunk (as well as gcc 4.8) produces wrong code for the
following testcase on x86_64-linux when compiled at -O3 in both 32-bit and
64-bit modes. This is a regression from 4.7.x.
$ gcc-trunk -v
gcc version 4.9.0 20130822 (experimental) [trunk revision 201915] (GCC)
$ gcc-4.7 -O3 reduced.c
$ a.out
1
$ gcc-trunk -O2 reduced.c
$ a.out
1
$ gcc-trunk -O3 reduced.c
$ a.out
0
$ gcc-4.8 -O3 reduced.c
$ a.out
0
$
-------------------------------------------
int printf (const char *, ...);
int a[2], b;
int main ()
{
for (b = 0; b < 2; b++)
{
a[0] = 1;
a[b] = 0;
}
printf ("%d\n", a[0]);
return 0;
}