struct default constructor, unions and bizaro behavior.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 10 13:57:42 PST 2014


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 ?


More information about the Digitalmars-d mailing list