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

            Bug ID: 104196
           Summary: wrong code at -O2 and above on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cnsun at uwaterloo dot ca
  Target Milestone: ---

$ gcc-trunk small.c -w -O2 ; ./a.out
g_1600=6
$ gcc-trunk small.c -w -O3 ; ./a.out
g_1600=6
$ gcc-trunk small.c -w -O1 ; ./a.out
$ gcc-trunk small.c -w -O0 ; ./a.out
$ cat small.c
int a = 6;
int main() {
  int b;
  for (;;) {
    b = a < 0 && 0 < -2147483647 - a ? 0 : a;
    if (b != 0x8C65C01D) {
      if (a < 6)
        printf("g_1600=%llu\n", (long long)a);
      goto c;
    }
  }
c:;
}
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.8MPqhHrPX1-gcc-builder/gcc/configure
--enable-languages=c,c++,lto --enable-checking-yes --enable-multiarch
--prefix=/scratch/software/gcc-trunk --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.1 20220123 (experimental) [master -g9718bc4b0] (GCC) 
$

Reply via email to