struct A { this(uint a, uint b) { begin = a; end = b; } union { struct { uint begin, end; } uint[2] arr; } } void main(){ enum y = A(10, 20); A y2 = A(10, 20); assert(y2.begin == y.begin && y2.end == y.end); //passes assert(y.arr == [0,0]); //passes, wtf ?! assert(y.arr == y2.arr); //fails } I dunno what was the last stance on unions in CTFE, but this bug also affects constfolded globals (which is tricky and nasty). So at minimum it's better to just reject it.
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/adb94ddfaf388505a0112539c7df3edada2d5435 fix Issue 6439 - [CTFE] union fields are initialized independently
Worksforme from 2.064.