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

            Bug ID: 60072
           Summary: wrong code (for code with an optimize attribute) at
                    -O0 on x86_64-linux-gnu in 32-bit mode
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk (as well as all earlier versions from 4.6.x to 4.8.x)
miscompiles the following code with an optimize attribute on x86_64-linux at
-O0 in 32-bit mode (but not 64-bit). 

$ 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 --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.9.0 20140204 (experimental) [trunk revision 207486] (GCC) 
$ 
$ gcc-trunk -m32 -O1 small.c; a.out
$ gcc-trunk -m64 -O0 small.c; a.out
$ 
$ gcc-trunk -m32 -O0 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.8.2 -m32 -O0 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.7.3 -m32 -O0 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.6.4 -m32 -O0 small.c; a.out
Segmentation fault (core dumped)
$ 


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


int i, *a = &i, **b = &a, c, d, **e = &a; 

__attribute__ ((optimize (1)))
static int *foo (int *p)
{
  *e = p;
  return 0;
}

int
main ()
{
  foo (&c);
  d < 1 && **b;
  return 0;
}

Reply via email to