struct Foo { union { int a; int b; } } struct Bar { __gshared union { // also fails if __gshared -> static int a; int b; } } void main (string[] args) { Foo x; Bar y; assert (cast(uint)(&x.a) == cast(uint)(&x.b)); // PASS assert (cast(uint)(&y.a) == cast(uint)(&y.b)); // FAIL }
Still happens with 2.109. Also: pragma(msg, Foo.b.offsetof); // 0 pragma(msg, Bar.b.offsetof); // Error: no property `offsetof` for `b` of type `int`