[Issue 16030] New: bad error message when trying to use union in CTFE
digitalmars-d-bugs at puremagic.com
Mon May 16 04:12:21 PDT 2016
Issue ID: 16030
Summary: bad error message when trying to use union in CTFE
Assignee: nobody at puremagic.com
Reporter: ag0aep6g at gmail.com
Encountered by Stefan who posted to D.learn:
byte f(int val)
u.i = val;
static byte forceCtfe = f(1); /* line 14 */
Fails compilation with:
test.d(14): Error: uninitialized variable 'i' cannot be returned from CTFE
I guess it's expected that unions don't work in CTFE, but the error message is
* There is no variable `i` on line 14. The function that actually fails CTFE
may be hidden anywhere in the call graph of `f`.
* The function tries to return `u.b`, not `u.i`.
* It's not obvious that "uninitialized" means "from a union".
More information about the Digitalmars-d-bugs