https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101780
Bug ID: 101780 Summary: Missing initializers whereas structure has default initializers Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: deco33000 at yandex dot com Target Milestone: --- Hi, The issue is a false positive warning being issued whereas even if there are missing initializers, the rest of the struct is default initialized. // Type your code here, or load an example. #include <iostream> #include <vector> using namespace std; struct A { union { int i = 82, j; }; int a = 98, b = 22; }; int main() { A polo = {.a = 45}; cout << polo.a << endl; cout << polo.i << endl; return 0; } warning: missing initializer for member 'A::<anonymous>' [-Wmissing-field-initializers] Try on godbolt: https://godbolt.org/z/ohnWPqcE5 Can you confirm it is the intended behavior? If so, could we make the message clearer, adding: "the following designated fields X,Y,Z will be default initialized. P,Q,R are left uninitialized." That way, it is much more useful as a warning, instead of making the dev fear of undefined behavior, when there is not. Thanks,