digitalmars.D.learn - Immutable unions
- bearophile (18/18) Mar 11 2012 Can you remind me why I can't define an immutable struct that contains a...
Can you remind me why I can't define an immutable struct that contains an union, like this? struct Foo1 { ushort bar2; } struct Foo2 { union { ubyte[2] bar1; ushort bar2; } } void main() { immutable Foo1 foo1 = { bar2: 100 }; // OK immutable Foo2 foo2 = { bar2: 100 }; // error } The latest DMD gives: test.d(12): Error: variable bug.main.foo2 is not a static and cannot have static initializer Bye and thank you, bearophile
Mar 11 2012