https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119032
Bug ID: 119032 Summary: Should using brace elison for designated initializer be reminded under '-pedantic-errors'? Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: accepts-invalid, diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- An interesting question that has also been submitted to LLVM' s bug tracker: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ struct A { int a; }; struct B { int b; }; struct C { A a; B b; }; C c{.a=0, .b={12}}; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GCC accepts this after gcc-11.3 and rejects it before by giving the following diagnostic: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:14:18: error: 'A' has no non-static data member named 'b' 14 | C c{.a=0, .b={12}}; | ^ Compiler returned: 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ https://godbolt.org/z/5nPzG3WGY While the real question might be that the code uses brace elision inside a designated initializer("{.a=0}"), which is actually a C99 extension, the diagnostic seems not that accurate. LLVM now ends up throwing a warning for that and erroring under '-pedantic-errors', but GCC currently does not provide any diagnostic even under '-pedantic-errors': https://godbolt.org/z/4fdWWTKqr