struct default constructor, unions and bizaro behavior.
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Thu Dec 11 22:12:06 PST 2014
On Wednesday, 10 December 2014 at 21:57:42 UTC, deadalnix wrote:
> struct S {
> union {
> T1 t1;
> T2 t2;
> }
>
> T3 t3;
> }
>
> T1 a1;
> T3 a3;
> S(a1, a3);
>
> This is erroring because t1 is set twice. It turns out that the
> second parameter of the struct map to t2 rather than t3.
>
> This behavior do not make any sense, ever. Why is that the
> default ?
Isn't using named union instead an option?
More information about the Digitalmars-d
mailing list