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

            Bug ID: 118638
           Summary: Miscompile with -Os and -O0/1/2/3
           Product: gcc
           Version: 14.1.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 -1 at -O0/1/2/3 and 3 at -Os:

```c
int printf(const char *, ...);
int a;
int b(int f) {
  int c = f ? 1 : 0, d = f ? 1 : 0, e = f ? 1 : 0;
  return c + d + e;
}
int g() {
  if (!((b(a + 3) + (a - 9 + a)) & 1))
    return -1;
  return 0;
}
int main() {
  int h = g();
  printf("%X\n", h);
}
```

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

It starts with x86-64 gcc 14.1.

Reply via email to