981 – CFTE fails in non-template and functions that takes no args.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 981 - CFTE fails in non-template and functions that takes no args.
Summary: CFTE fails in non-template and functions that takes no args.
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:
Depends on:
Blocks:
Reported: 2007年02月18日 23:33 UTC by Kevin Bealer
Modified: 2014年02月16日 15:22 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 Kevin Bealer 2007年02月18日 23:33:20 UTC
In the following code, I think A, B, C, and D should work, but only A works. If B, C, or D is uncommented, an error is reported during compilation. I'm not sure if this is one or more bugs, but at the moment the CFTE stuff seems to require the called function to take parameters and also to be called from a template. (I'm guessing this has to do with constant folding working differently in different contexts.)
Kevin
//---------------
char[] one(char[] hi)
{
 return "abc "~hi;
}
char[] two()
{
 return "xyz";
}
struct A(T) {
 const char[] z = one("x");
}
/+
//dmd: interpret.c:96: Expression*
//FuncDeclaration::interpret(Expressions*): Assertion `parameters &&
//parameters->dim == dim' failed.
struct B(T) {
 const char[] z = two();
}
+/
/+
// t1.d(28): Error: cannot evaluate (one)("x") at compile time
struct C {
 const char[] z = one("x");
}
+/
/+
//t1.d(25): Error: cannot evaluate (two)() at compile time
struct D {
 const char[] z = two();
}
+/
int main()
{
 A!(int) a;
 //B!(int) b;
 //C c;
 //D d;
 
 return 0;
}
Comment 1 Justin C Calvarese 2007年02月22日 11:48:03 UTC
Fixed in DMD 1.007


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