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

            Bug ID: 82377
           Summary: wrong code at -O1 and above on x86_64-linux-gnu
           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: ---

$ gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/home/su/software/tmp/gcc/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/home/su/software/tmp/gcc/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 8.0.0 20170930 (experimental) [trunk revision 253320] (GCC)
$
$ gcctk -O0 small.c; ./a.out
0
$ gcc-7.2.0 -O1 small.c; ./a.out
0
$
$ gcctk -O1 small.c
$ ./a.out
1
$


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


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

struct A
{ 
  int b;
  int c;
  int d;
  int e;
  int f;
  long g;
} h;

int i;

void o (int m)
{ 
  struct A p[9] = { { 1, 0, 0, 0, 0, 0 } };
  h = p[3];
}

void n (int q)
{ 
  o (i);
}

void l ()
{ 
  n (i);
}

void r ()
{ 
  l ();
  if (!i)
    return;
  while (1)
    ;
}

int main ()
{ 
  r ();
  printf ("%d\n", h.b);
  return 0;
}

Reply via email to