https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96868
Bug ID: 96868 Summary: C++20 designated initializer erroneous warnings Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matt at godbolt dot org Target Milestone: --- The following code, with -Wall -Wextra, GCC 10.x or trunk, -std=c++20: ``` struct MyObj { MyObj(); }; struct Test { int a{}; MyObj obj; }; Test t() { Test t{.a = 1}; return t; } ``` Creates a warning: ``` <source>: In function 'Test t()': <source>:11:18: warning: missing initializer for member 'Test::obj' [-Wmissing-field-initializers] 11 | Test t{.a = 1}; | ^ ``` The "obj" is not missing initialization: the generated code correctly calls MyObj::MyObj(). clang issues no diagnostic on the same code (even with -Weverything). May be a duplicate of bug #82283 or bug #84685, but those have far more complex-looking initialiser lists. CE link: https://godbolt.org/z/b75P6r