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