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

            Bug ID: 111648
           Summary: Wrong code at -O2/3 on x86_64-linux-gnu since
                    r14-3243-ga7dba4a1c05
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
                CC: prathamesh3492 at gcc dot gnu.org
  Target Milestone: ---

gcc at -O2/3 produced the wrong code

Bisected to r14-3243-ga7dba4a1c05

Compiler explorer: https://godbolt.org/z/1bvWTrEK1

$ cat a.c
int printf(const char *, ...);
int a;
int *b = &a;
static int **c = &b;
static int d;
short e;
char f;
int main() {
  f = -21;
  for (; f < -5; f++) {
    e = f ^ 3;
    d = *b;
    **c = e;
  }
  printf("%d\n", d);
}
$
$ gcc -O0 a.c && ./a.out
-6
$ gcc -O2 a.c && ./a.out
2
$

Reply via email to