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

            Bug ID: 79188
           Summary: wrong code at -O3 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: ---

It 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 20170122 (experimental) [trunk revision 244756] (GCC) 
$ 
$ gcc-trunk -O2 small.c
$ ./a.out
$ 
$ gcc-trunk -O3 small.c
$ ./a.out
Aborted (core dumped)
$ 


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


int a, b, c, d, e, f, h, j, k;

static void fn1 ()
{
  int g = 1, i;
  if (!f)
    {
      for (; d < 1; d++)
        for (i = 0, j = 1; i < 1; i = j)
          a = 2;
      for (; e < 1; e++)
        {
          for (; k; k++)
          L:
            ;
          for (c = 0; c < 2; c++)
            {
              for (i = 0; i < 4; i++)
                {
                  for (; h; h++)
                    g = 0;
                  b = 0;
                }
              if (b)
                goto L;
            }
          a = 0;
        }
      if (g < 0)
        goto L;
    }
}

int main ()
{
  fn1 ();

  if (a != 0) 
    __builtin_abort ();

  return 0; 
}

Reply via email to