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

            Bug ID: 86927
           Summary: Gcc miscompiles at -O3 on valid code
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: helloqirun at gmail dot com
  Target Milestone: ---

It appears to be a recent regression. And it happens at -O3 only.

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 9.0.0 20180812 (experimental) [trunk revision 263494] (GCC)


$ gcc-trunk abc.c ; ./a.out
$ gcc-trunk -O2 abc.c ; ./a.out
$ gcc-trunk -O3 abc.c ; ./a.out
Aborted (core dumped)


$ cat abc.c
int a[28];
int b;
void abort();
int main() {
  a[4] = 1;
  int c = 1;
  for (; b < 8; b++)
    if (a[b])
      c = 0;
  if (c)
    abort();
}

Reply via email to