https://issues.dlang.org/show_bug.cgi?id=15938
RazvanN <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #3 from RazvanN <[email protected]> --- (In reply to John Colvin from comment #2) > Simplified example: > > struct S { > union { > // works if order swapped > int b; > int[1] a; > } > > this(int v) { > a[0] = v; > } > } > auto s = S(2); > > void main() { > assert(s.a[0] == 2); // fails > assert(S(2).a[0] == 2); // OK > } It seems that ctfe rewrites `auto s = S(2)` to `auto s = S(0, [2)`. So it does not seem to understand that a and b are inside a union and therefore only the first initializer (0) will be taken into account. --
