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

            Bug ID: 111444
           Summary: Wrong code at -O2/3/s on x86_64-gnu since
                    r14-3226-gd073e2d75d9
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
                CC: mjambor at suse dot cz
  Target Milestone: ---

gcc at -O2/3/s produced the wrong code.

Bisected to r14-3226-gd073e2d75d9

Compiler explorer: https://godbolt.org/z/xWj9z8foe

$ cat a.c
int printf(const char *, ...);
int a = 3, d, e;
int *b = &a;
char c;
short f;
const int **g;
static long h(int **i, int **j) {
  const int *k[46];
  const int **l = &k[5];
  *j = &e;
  g = l;
  for (; d; d = d + 1)
    ;
  **i = 0;
  return f;
}
int main() {
  int *m = &a;
  h(&m, &m);
  c = *b;
  printf("%d\n", c);
}
$
$ gcc -O0 a.c && ./a.out
3
$ gcc -O2 a.c && ./a.out
0
$

Reply via email to