2960 – CTFE rejects static array to dynamic array casts

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2960 - CTFE rejects static array to dynamic array casts
Summary: CTFE rejects static array to dynamic array casts
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2009年05月10日 06:52 UTC by Christian Kamm
Modified: 2014年04月18日 09:12 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Christian Kamm 2009年05月10日 06:52:16 UTC
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 Walter Bright 2009年09月03日 13:28:38 UTC
Fixed dmd 1.047


AltStyle によって変換されたページ (->オリジナル) /