Bug 59162 - wrong code (hangs) at -Os and above on x86_64-linux-gnu (affecting 4.7.3 and earlier versions)
Summary: wrong code (hangs) at -Os and above on x86_64-linux-gnu (affecting 4.7.3 and ...
Status: RESOLVED DUPLICATE of bug 35634
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-17 20:45 UTC by Zhendong Su
Modified: 2013-11-17 21:47 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2013-11-17 20:45:03 UTC
GCC 4.7.3 and earlier versions miscompile the following code on x86_64-linux at -Os and above in both 32-bit and 64-bit modes.  But I did not check the latest 4.7 branch. 

It affects neither the current trunk nor 4.8.x. 

$ gcc-4.7.3 -O1 small.c; a.out
1
$ gcc-4.7.3 -Os small.c; a.out
^C
$ gcc-4.6.4 -Os small.c; a.out
^C
$ gcc-4.8.2 -Os small.c; a.out
1
$ gcc-trunk -Os small.c; a.out
1
$ 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 --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 20131117 (experimental) [trunk revision 204920] (GCC) 
$


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


int printf (const char *, ...);

int a, *b = &a;

int
main ()
{
  short c = 0;
 lbl:
  ++c;
  *b |= 1;
  if (c)
    goto lbl;
  printf ("%d\n", a);
  return 0;
}
Comment 1 Andrew Pinski 2013-11-17 21:33:09 UTC
Dup of bug 35634.

*** This bug has been marked as a duplicate of bug 35634 ***
Comment 2 Zhendong Su 2013-11-17 21:47:48 UTC
(In reply to Andrew Pinski from comment #1)
> Dup of bug 35634.
> 
> *** This bug has been marked as a duplicate of bug 35634 ***

Sorry for the dup; didn't know about this earlier report.