Bug 10937 – struct inside union gives uninitialized error in CTFE

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-31T18:29:00Z
Last change time
2013-09-23T00:45:17Z
Assigned to
nobody
Creator
destructionator

Comments

Comment #0 by destructionator — 2013-08-31T18:29:57Z
=== struct Test { union { ubyte[1] a; struct { ubyte b; } } this(ubyte B) { this.b = B; // this triggers the error below // this.a[0] = B; // this works } } enum test = Test(0); // test30.d(9): Error: uninitialized variable 'b' cannot be returned from CTFE === Both constructor lines work fine at runtime.
Comment #1 by github-bugzilla — 2013-09-17T22:56:14Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b33b138f632c049b5cfb52ebbbac35b426557f4c Fix bug 10937 struct inside union gives uninitialized error in CTFE Remove over-zealous assert, add comments to explain why.