http://d.puremagic.com/issues/show_bug.cgi?id=11132
Summary: Odd diagnostic with C-style struct initializer when union field is present Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: andrej.mitrov...@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 2013-09-27 15:35:22 PDT --- ----- struct S { int x; union { int a; int b; } int z; } void main() { S s = { 1, 2, 3 }; } ----- $ dmd test.d test.d(15): Error: variable test.main.s is not a static and cannot have static initializer A more appropriate diagnostic is emitted when using the regular D-style syntax: S s = S(1, 2, 3); test.d(17): Error: overlapping initialization for b *However*, C (or is it just C++?) supports a special syntax for initializing union fields: S s = { 1, { 2 }, 3 }; But the above is an error in D: test.d(17): Error: a struct is not a valid initializer for a int I don't know if we want to support this. But we at least have to fix the diagnostic in the first example. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------