digitalmars.D.bugs - [Issue 6439] New: [CTFE] union field are initialized independently
- d-bugmail puremagic.com (42/42) Aug 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6439
http://d.puremagic.com/issues/show_bug.cgi?id=6439 Summary: [CTFE] union field are initialized independently Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dmitry.olsh gmail.com --- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2011-08-05 05:18:59 PDT --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 05 2011