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

            Bug ID: 79737
           Summary: wrong code at -O2 and -O3 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 appears to be a recent regression. 


$ 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.1/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.1 20170227 (experimental) [trunk revision 245750] (GCC) 
$ 
$ gcc-trunk -Os small.c; ./a.out
0
$ gcc-trunk -O2 small.c; ./a.out
31
$ 


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


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

#pragma pack(1)
struct S
{
  int b:18;
  int c:1;
  int d:24;
  int e:15;
  int f:14;
} i;
int g, j, k;
static struct S h;

void fn1 ()
{
  for (j = 0; j < 6; j++)
    k = 0;
  for (; k < 3; k++)
    {
      struct S m = { 5, 0, -5, 9, 5 };
      h = m;
      if (g)
        i = m;
      h.e = 0;
    }
}

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

Reply via email to