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

            Bug ID: 58865
           Summary: wrong code at -Os on x86_64-linux-gnu
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following code on x86_64-linux at -Os in
64-bit mode. 

This is a regression from 4.8.x. 

Perhaps related to 58685 (which also affects 4.7.x and 4.8.x though)? 

$ 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 20131024 (experimental) [trunk revision 204004] (GCC) 
$ 
$ gcc-trunk -m64 -O1 small.c; a.out
$ gcc-trunk -m64 -O2 small.c; a.out
$ gcc-trunk -m32 -Os small.c; a.out
$ gcc-4.8.2 -m64 -Os small.c; a.out
$ 
$ gcc-trunk -m64 -Os small.c; a.out
a.out: :1534914408: H?l$?L?d$?H?-? : Assertion `(null)' failed.
Aborted (core dumped)
$ 


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


int *c, **d = &c, e, f;

void __assert_fail (int *, char *);

void
fn1 ()
{
  fn1 ();
  c ? (void) 0 : __assert_fail (0, "");
}

void
fn2 (int p1, int **p2)
{
  *p2 = &f;
  c ? (void) 0 : __assert_fail (0, "");
  for (e = 1; e < 1; e--)
    if (p1)
      break;
}

int
main ()
{
  fn2 (0, d);
  return 0;
}

Reply via email to