http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58830
Bug ID: 58830
Summary: wrong code at -O3 on x86_64-linux-gnu (affecting
4.8.x, but not trunk or 4.7.x)
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The following testcase is miscompiled by 4.8.2 (as well 4.8.0 and 4.8.1) on
x86_64-linux at -O3 in both 32-bit and 64-bit modes.
It works with the current gcc trunk, 4.7.x and 4.6.x.
$ gcc-4.8.2 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8.2
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.2/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-checking=release
--with-gmp=/home/su/software/local/gcc-4.8.2
--with-mpfr=/home/su/software/local/gcc-4.8.2
--with-mpc=/home/su/software/local/gcc-4.8.2
--with-cloog=/home/su/software/local/gcc-4.8.2
--prefix=/home/su/software/local/gcc-4.8.2
Thread model: posix
gcc version 4.8.2 (GCC)
$
$ gcc-4.8.2 -O2 small.c; a.out
0
$ gcc-4.7.3 -O3 small.c; a.out
0
$ gcc-4.6.4 -O3 small.c; a.out
0
$ gcc-trunk -O3 small.c; a.out
0
$
$ gcc-4.8.2 -O3 small.c; a.out
2
$ gcc-4.8.1 -O3 small.c; a.out
2
$ gcc-4.8.0 -O3 small.c; a.out
2
$
---------------------------------
int printf (const char *, ...);
int b, c, d, f, g, h, i, j[6], *l = &b, *m, n, *o, r;
char k;
static int
foo ()
{
char *p = &k;
for (; d; d++)
if (i)
h = 0;
else
h = c || (r = 0);
for (f = 0; f < 2; f++)
{
unsigned int q;
*l = 0;
if (n)
*m = g;
if (g)
o = 0;
for (q = -8; q >= 5; q++)
(*p)--;
}
return 0;
}
int
main ()
{
foo ();
printf("%d\n",
j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
^ (k & 15)]);
return 0;
}