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

            Bug ID: 123985
           Summary: Inconsistent -Wuninitialized behavior under -O0
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qcf at ecnelises dot com
  Target Milestone: ---

```
struct A { A() = default; int m; double d; };
struct B { B() {} int m; double d; };
struct C { int m; double d; };
void foo(int);
int main() {
  A a; foo(a.m);
  B b; foo(b.m);
  C c; foo(c.m);
}
```

- With -Wuninitialized -O, all three lines trigger warnings.
- With -Wuninitialized -O0, only A and C trigger warnings.
- Reorder code in main to B-C-A and with -O0, only C triggers warning.

Reply via email to