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

            Bug ID: 111137
           Summary: Wrong code at -O2/3 since r12-1000-g6924b5e6bd3
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
                CC: rguenth at gcc dot gnu.org
  Target Milestone: ---

gcc at -O2/3 produces the wrong code.

Bisected to r12-1000-g6924b5e6bd3

Compiler explorer: https://godbolt.org/z/9fo5dxxhf

$ cat a.c
int printf(const char *, ...);
char a;
int b[3][8];
int c, e = 1, f, g;
short d;
int main() {
  for (; e >= 0; e--) {
    d = 1;
    for (; d >= 0; d--) {
      c = 0;
      for (; c <= 1; c++) {
        b[0][d * 2 + c + 1] = 0;
        g = a <= '7';
        b[g - 1 + d][c] ^= 1;
      }
    }
  }
  printf("%d\n", b[0][1]);
}
$
$ gcc -O0 a.c && ./a.out
1
$ gcc -O2 a.c && ./a.out
0
$

Reply via email to