[Bug rtl-optimization/57343] New: wrong code on x86_64-linux at -Os and above
dhazeghi at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Mon May 20 21:12:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57343
Bug ID: 57343
Summary: wrong code on x86_64-linux at -Os and above
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: dhazeghi at yahoo dot com
The following code is miscompiled on x86_64-linux at -Os and above with gcc
trunk and at -O2 and above with gcc 4.8. It outputs 0 rather than 4 as it
should. It works correctly with gcc 4.7.
$ gcc-trunk -v
gcc version 4.9.0 20130520 (experimental) [trunk revision 199099] (GCC)
$ gcc-trunk -O1 wrong.c
$ ./a.out
4
$ gcc-4.7 -Os wrong.c
$ ./a.out
4
$ gcc-trunk -Os wrong.c
$ ./a.out
0
$
------------------------------
int printf (const char *, ...);
int a[6];
int b, c, d, e;
int f[10] = { 0, 0, 0, 0, 0, 1075L };
int *g = &f[5];
char h;
unsigned i;
void
fn1 (int p1)
{
b = a[p1];
}
int
main ()
{
for (; e < 6; e++)
a[e] = e;
i = -14;
for (; i >= 8; i++)
{
d = --c;
h = d * 100L;
if (h);
else
{
*g = 0;
break;
}
}
fn1 (f[5] >> 8 & 15);
printf ("%d\n", b);
return 0;
}
More information about the Gcc-bugs
mailing list