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.
Comment #1 by k.hara.pg — 2013-04-01T23:54:13Z
Comment #2 by k.hara.pg — 2013-04-02T07:37:53Z
*** Issue 9847 has been marked as a duplicate of this issue. ***
Comment #3 by github-bugzilla — 2013-04-03T16:47:29Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/79309eb016fa7271d0477a4adf77560fa3396d6c fix Issue 9775 - Can no longer create a const Date in CTFE if the variable is explicitly typed https://github.com/D-Programming-Language/dmd/commit/ab53fcc44aadd5dd108525c1bf042406cf34c51f Merge pull request #1824 from 9rnsr/fix9775 [REG2.062] Issue 9775 - Can no longer create a const Date in CTFE if the variable is explicitly typed