Bug 9775 – Can no longer create a const Date in CTFE if the variable is explicitly typed
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-21T02:15:00Z
Last change time
2013-04-03T16:48:36Z
Keywords
ice, pull
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2013-03-21T02:15:15Z
In 2.061, this compiled:
import std.datetime;
const Date date = Date(2012, 12, 21);
void main() {}
In 2.062 (and the current master), it gives
/usr/include/D/phobos/std/datetime.d(13542): Error: Internal Compiler Error: CTFE literal cast(short)1
dmd: ctfeexpr.c:353: Expression* copyLiteral(Expression*): Assertion `0' failed.
Aborted (core dumped)
It works if it's changed to
import std.datetime;
const date = Date(2012, 12, 21);
void main() {}
It also works if date is made non-const
Date date = Date(2012, 12, 21);
But it doesn't work even without const, if it's an enum
enum Date date = Date(2012, 12, 21);
though as with normal variables, if the type is not given explicitly to the enum, it compiles just fine.