Bug 981 – CFTE fails in non-template and functions that takes no args.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-02-18T23:33:00Z
Last change time
2014-02-16T15:22:12Z
Assigned to
bugzilla
Creator
kevinbealer
Comments
Comment #0 by kevinbealer — 2007-02-18T23:33:20Z
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;
}