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

            Bug ID: 111336
           Summary: Wrong code at -O2/3 since r14-2472-g14b10ff30ad
           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: hubicka at gcc dot gnu.org
  Target Milestone: ---

gcc at -O2/3 produced the wrong code on the following testcase.

Bisected to r14-2472-g14b10ff30ad

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

$ cat a.c
int printf(const char *, ...);
int a, b;
long c = 3521733542;
int d[2];
int e(int f, int g) {
  if (f == 0)
    return 0;
  if (f > 200)
    return 0;
  if (g)
    return 5 * f;
  return 0;
}
int main() {
  int h = 0;
  for (; e((int)c + 773233762, c + 60) + 773163185 + h < 2; h++)
    d[h] = b;
  printf("%X\n", a);
}
$
$ gcc -O0 a.c && ./a.out
0
$ gcc -O2 a.c && ./a.out
Segmentation fault
$

Reply via email to