https://issues.dlang.org/show_bug.cgi?id=19917
Nicholas Wilson <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] | |m --- Comment #1 from Nicholas Wilson <[email protected]> --- The way it currently works is the first member of a union is the one that dictates the .init of the union struct S { union { int x; float y; // COMPILE ERROR, 'x' already initialised! } union { int z; float w = void; // <- this is fine } } S s; assert( (cast(int*)&s)[0 .. 2]) == [0,0]); // passes reverse the order and the assert fails. If you want void initialisation then if know (or can compute) the size of the union (say N) then you can make the first member a `void[N] dummy;`. If the docs need to make that more explicit do say so, go forth and complain on the forums! --
