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

            Bug ID: 78482
           Summary: wrong code at -O3 in both 32-bit and 64-bit modes on
                    x86_64-linux-gnu
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com
  Target Milestone: ---

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20161122 (experimental) [trunk revision 242702] (GCC)
$ gcc-trunk -O3 small.c ; ./a.out
2
$ gcc-trunk -O2 small.c ; ./a.out
$ cat small.c
int printf(const char*, ...);
short a = 65531;
int b = 3, f;
char c, d;
void fn1(int p1) {
  short e;
  b = f;
  if (f > p1 && p1)
  L:
  for (e = 0; 0;)
    ;
  else if (d) b = 0 >= b;
  for (; e <= 3; e++) {
    if (b)
      continue;
    b = 3;
    goto L;
  }
}

int main() {
  for (; c >= 0; c--) {
    if (!b) {
      printf("%d\n", 2);
      continue;
    }
    fn1(a);
  }
  return 0;
}
$
$

Reply via email to