Bug 2960 – CTFE rejects static array to dynamic array casts

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2009-05-10T06:52:00Z
Last change time
2014-04-18T09:12:04Z
Keywords
patch, rejects-valid
Assigned to
bugzilla
Creator
kamm-removethis

Comments

Comment #0 by kamm-removethis — 2009-05-10T06:52:16Z
Test case: char[] foo(char[] source) { return ""; } const v = "bar"; const r = foo(v); Result: Error: cannot evaluate foo(cast(char[])v) at compile time This works in D2 because of changes to Cast in constfold.c. LDC backported the changes by adding this code from the D2 frontend: if (e1->op == TOKstring) { if (tb->ty == Tarray && typeb->ty == Tarray && tb->nextOf()->size() == typeb->nextOf()->size()) { return expType(to, e1); } }
Comment #1 by bugzilla — 2009-09-03T13:28:38Z
Fixed dmd 1.047