[Issue 981] New: CFTE fails in non-template and functions that takes no args.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 18 21:33:27 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=981
Summary: CFTE fails in non-template and functions that takes no
args.
Product: D
Version: 1.006
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: kevinbealer at gmail.com
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;
}
--
More information about the Digitalmars-d-bugs
mailing list