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

            Bug ID: 77309
           Summary: wrong code at -Os and above on x86_64-linux-gnu (in
                    the 64-bit mode)
           Product: gcc
           Version: 7.0
            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 4.8.x and later, and is a regression from 4.7.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 20160821 (experimental) [trunk revision 239642] (GCC) 
$ 
$ gcc-trunk -O1 small.c; ./a.out
$ gcc-4.7 -Os small.c; ./a.out
$ 
$ gcc-trunk -Os small.c
$ ./a.out
Aborted (core dumped)
$ 


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


int a, b;

int main ()
{
  long c = 1 % (2 ^ b);
  c = -c & ~(~(b ^ ~b) || a);

  if (c >= 0)
    __builtin_abort ();

  return 0;
}

Reply via email to