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

            Bug ID: 83269
           Summary: Wrong constant folding
           Product: gcc
           Version: 8.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 8.0.0 for x86_64 miscompiles the following code.

Reproduces on gcc-5.1.0 to gcc-6.3.0 and gcc-8.0.0 with -O1, and on gcc-4.4.7
or later with -O2.

% cat test.c
int main (void)
{
  volatile unsigned char a = 1;
  long b = 0x80000000L;
  int c = - ( (int)(-b) - (-0x7FFFFFFF*a) );
  if (c != 1) __builtin_abort();
  return 0;
}

% gcc-8.0 test.c -O1
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-8.0 -v
Using built-in specs.
COLLECT_GCC=gcc-8.0
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --program-suffix=-8.0 --disable-multilib
--enable-languages=c
Thread model: posix
gcc version 8.0.0 20171109 (experimental) (GCC)

Reply via email to