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

            Bug ID: 111839
           Summary: Wrong code at -O3 on x86_64-linux-gnu since
                    r12-2097-g9f34b780b0
           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: rguenth at gcc dot gnu.org
  Target Milestone: ---

gcc at -O3 produced the wrong code.

Bisected to r12-2097-g9f34b780b0

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

$ cat a.c
int printf(const char *, ...);
long a;
int b, c, e, g, i;
long *d, *h;
char f = -26;
int main() {
  long j;
  c = 0;
  for (; c != 7; ++c) {
    long k=0;
    long l = k;
    long **m = &d;
    for (; f + i!=0; i++)
      h = &l;
    g = h != (*m = &j);
    int *n = &b;
    *n = g;
    for (; e;)
      for (; a; a = a + 1)
        ;
  }
  printf("%d\n", b);
}
$
$ gcc -fsanitize=address,undefined a.c && ./a.out
1
$ gcc -O3 a.c && ./a.out
0
$

Reply via email to