http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58653

            Bug ID: 58653
           Summary: wrong code (segfaults) at -O3 on x86_64-linux-gnu in
                    64-bit mode (affecting gcc 4.6 to trunk)
           Product: gcc
           Version: 4.9.0
            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 4.6, 4.7, and 4.8) mis-compiles the following
code on x86_64-linux at -O3 in 64-bit mode, resulting in a segfault. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131006 (experimental) [trunk revision 203227] (GCC) 
$ 
$ gcc-trunk -m64 -O2 small.c; a.out
$ gcc-trunk -m32 -O3 small.c; a.out
$
$ gcc-trunk -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.8 -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.7 -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.6 -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$  

---------------------------------

int a, c, e[5][2]; 
unsigned int d;

int
main ()
{
  for (d = 0; d < 2; d++)
    if (a ? 0 : e[c + 3][d] & e[c + 4][d])
      break;
  return 0;
}

Reply via email to