[Bug tree-optimization/87132] New: Gcc miscompiles at -O2 on valid code

helloqirun at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Aug 28 21:51:00 GMT 2018


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

            Bug ID: 87132
           Summary: Gcc miscompiles at -O2 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 seems to be a recent regression starting from r263875 (need double check).


$ 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 20180828 (experimental) [trunk revision 263917] (GCC)




$ gcc-trunk abc.c ; ./a.out
0
$ gcc-trunk -O2 abc.c ; ./a.out
4


$ cat abc.c
int printf(const char *, ...);
int a, b;
short c;
char d;
int main() {
  int e[] = {4, 4, 4, 4, 4, 4, 4, 4, 4};
  d = 8;
  for (; d; d--) {
    a = 0;
    for (; a <= 8; a++) {
      c = e[1];
      e[d] = b;
    }
  }
  printf("%d\n", c);
}


More information about the Gcc-bugs mailing list