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

            Bug ID: 68528
           Summary: Wrong constant folding
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC-6.0 for x86_64 miscompiles the following code.

$ cat test.c
#define INT_MIN ( -2147483647 - 1 )

int main (void)
{
    int  x0 = INT_MIN;
    long x1 = 0L;
    int  x2 = 0;
    int  t  = ( 0 || ( INT_MIN - (int) ( x0 - x1 ) ) );

    if ( t != 0 ) { x2 = t; __builtin_abort(); }

    return 0;
}

$ gcc-6.0 test.c -O2

$ ./a.out
zsh: abort      ./a.out

$ gcc-6.0 -v
Using built-in specs.
COLLECT_GCC=gcc-6.0
COLLECT_LTO_WRAPPER=/home/ishiuraken/opt/gcc-6.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/ishiuraken/opt/gcc-6.0
--program-suffix=-6.0 --enable-laungages=c --disable-bootstrap
Thread model: posix
gcc version 6.0.0 20151112 (experimental) (GCC)

Reply via email to