[Bug tree-optimization/78428] New: wrong code at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode

su at cs dot ucdavis.edu gcc-bugzilla@gcc.gnu.org
Sun Nov 20 00:08:00 GMT 2016


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

            Bug ID: 78428
           Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu in
                    64-bit mode
           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: ---

It also affects 5.x and 6.x, and is a regression from 4.9.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 20161119 (experimental) [trunk revision 242621] (GCC) 
$ 
$ gcc-trunk -Os small.c; ./a.out
$ gcc-4.9 -O2 small.c; ./a.out
$ 
$ gcc-trunk -O2 small.c
$ timeout -s 9 10 ./a.out
Killed
$ 


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


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

struct S0
{
  int f2;
  int:16;
  int f4:18;
};

int a = 5, c, e, i;
struct S0 b = { 2, 0 };
static struct S0 g[] = { { 7, 2 } };
int f = 1, h;

int main ()
{
  for (; a; a--)
    {
      volatile struct S0 *j = &b;
    L1:
      if (!f || h)
        {
          printf ("%d\n", e);
          goto L1;
        }
      for (c = 0; c < 1; c++)
        i = 0;
      for (; i < 1; i++)
        *j = g[0];
    }
  return 0;
}


More information about the Gcc-bugs mailing list