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

            Bug ID: 78248
           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 20161107 (experimental) [trunk revision 241911] (GCC) 
$ 
$ gcc-trunk -O1 small.c; ./a.out
$ gcc-6.2 -Os small.c; ./a.out
$ 
$ gcc-trunk -Os small.c
$ ./a.out
Segmentation fault (core dumped)
$ 


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


static struct S
{
  int f0:15;
} a;

int b[1], c = 2, d, e, f, g;

int main ()
{
  struct S h = { -2 };
  for (; e < 640; e++)
    for (; f < 1; f++)
      {
        if (c < 2)
          {
            d = b[e];
            h = a;
          }
        g = c;
        c = 1;
        if (!h.f0)
          break;
        c = g;
      }
  return 0; 
}

Reply via email to