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

            Bug ID: 118915
           Summary: Miscompile at -O2
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yunboni at smail dot nju.edu.cn
  Target Milestone: ---

This code prints 2 at -O2 and -22 at -O0/1/3/s:

```c
int printf(const char *, ...);
int a;
int b(int c, int d, int e, int f) {
  if (!d || !e)
    return -22;
  if (c > 16)
    return -22;
  if (!f)
    return -22;
  return 2;
}
int main() {
  int g = b(a + 21, a + 6, a + 34, a + 26);
  printf("%d\n", g);
}
```

Compiler Explorer: https://godbolt.org/z/MYGc4MeEr

It seems to fail from gcc 5.1.

Reply via email to