This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/61437] New: wrong code on x86_64-linux-gnu when compile separately


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61437

            Bug ID: 61437
           Summary: wrong code on x86_64-linux-gnu when compile separately
           Product: gcc
           Version: 4.10.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 miscompiles the following files (foo.c and main.c) on
x86_64-linux in both 32-bit and 64-bit modes. 

This is a regression from 4.9.x. 

The merged file (merged.c) does not trigger the bug.


$ 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.10.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.10.0 20140606 (experimental) [trunk revision 211322] (GCC) 
$ 
$ gcc-trunk -O2 -c foo.c
$ gcc-trunk -O2 -c main.c
$ gcc-trunk -O2 foo.o main.o
$ a.out
a.out: foo.c:9: foo: Assertion `b == 0' failed.
Aborted (core dumped)
$ 
$ gcc-4.9.0 -O2 -c foo.c
$ gcc-4.9.0 -O2 -c main.c
$ gcc-4.9.0 -O2 foo.o main.o
$ a.out
$ 
$ gcc-trunk -O2 merged.c
$ a.out
$ 
$ cat foo.c
#include <assert.h>

extern int *b, **c; 

int foo (void)
{
  int *t = 0; 
  *c = t;
  assert (b == 0);
}
$ cat main.c
extern int foo (void); 

int a, *b = &a, **c = &b;

int main (void)
{
  foo ();
  return 0;
}
$ 
$ cat merged.c
#include <assert.h>

int a;
int *b = &a;
int **c = &b;

int
foo ()
{
  int *t = 0;
  *c = t;
  assert (b == 0);
}

int
main ()
{
  foo ();
  return 0;
}
$


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]