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

            Bug ID: 79187
           Summary: wrong code at -Os on x86_64-linux-gnu (generated code
                    segfaults)
           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 seems 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 -O1 small.c
$ ./a.out
$ 
$ gcc-trunk -Os small.c
$ ./a.out
Segmentation fault (core dumped)
$ 


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


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

int a, b = -600, c, d[] = { 0 }, e, f, g = -1, h;
unsigned i = ~0;

int main ()
{
  for (; h < 2; h++)
    {
      if (a > 0)
        printf ("%d\n", d[b]);
      f = ~(b % i);
      c = g | (f && g) && e | b;
      a = ~(~g & b);
    }
  return 0; 
}

Reply via email to