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

            Bug ID: 111365
           Summary: Wrong code at -O3 since r13-1268-g8c99e307b20
           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: aldyh at redhat dot com
  Target Milestone: ---

gcc at -O3 produced the wrong code.

Bisected to r13-1268-g8c99e307b20

Compiler explorer: https://godbolt.org/z/5rb3sTG3E

$ cat a.c
int printf(const char *, ...);
int a, c, d, e = -1233286202, f = -1233286202;
short b, g, j;
int k(int l) {
  if (l <= 0 || &c + l > &d)
    return -1;
  return 0;
}
int m(int l) {
  int h = k(l);
  return h;
}
int main() {
  int i = 0;
  for (;
       (m(f + 1233286202) + e + (f + 1233286202) + 1233220671) + 65532U + i <
9;
       i++)
    g = 6;
  printf("%d\n", g);
}
$
$ gcc -O0 a.c && ./a.out
6
$ gcc -O3 a.c && ./a.out
0
$ gcc -fsanitize=address,undefined a.c && ./a.out
6
$

Reply via email to