https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87032
Bug ID: 87032 Summary: incorrect nested structure with union initialization Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vadim at sukhomlinov dot co Target Milestone: --- For the code: /**************/ struct f1 {int x,y;}; struct f2 {int x,y,z,t;}; struct T { const char * name; union { struct f1 fn1; struct f2 fn2; } d; }; extern "C" void p(struct T); int main(){ p({"%x",{.fn2={1,2,3,4}}}); } /******************/ gcc 7.3 generates: <source>: In function 'int main()': <source>:15:26: internal compiler error: in reshape_init_class, at cp/decl.c:5802 p({"%x",{.fn2={1,2,3,4}}}); ^ mmap: Invalid argument gcc 8.1/8.2: <source>: In function 'int main()': <source>:15:26: error: could not convert '{"%x", {{1, 2, 3, 4}}}' from '<brace-enclosed initializer list>' to 'T' p({"%x",{.fn2={1,2,3,4}}}); ^ Compiler returned: 1 At the same time Clang starting 3.1 and higher generates valid code. Testing done using https://godbolt.org/