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

            Bug ID: 78218
           Summary: wrong code at -Os and above on x86_64-linux-gnu (in
                    both 32-bit and 64-bit modes)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

This is a regression from 6.2.x. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20161104 (experimental) [trunk revision 241845] (GCC) 
$ 
$ gcc-trunk -O1 small.c; ./a.out
1
$ gcc-6.2 -Os small.c; ./a.out
1
$ 
$ gcc-trunk -Os small.c; ./a.out
0
$ 


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


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

struct 
{
  int v;
} a[2];

int b; 

int main ()
{
  a[1].v = 1;
  a[0] = a[1];
  a[1].v = 0;
  for (; b < 1; b++)
    printf ("%d\n", a[0].v);
  return 0;
}

Reply via email to