Seems to be a memory corruption problem. Doesn't happen if unused, unused2 are removed.
---------
struct V {
int a;
int b;
}
V f()
{
int q = 0;
int unused;
int unused2;
return V(q, 0);
}
void main()
{
const w = f();
}
==========================
Probably more helpful is this version, which prints:
No expression copy for: unused
just before it crashes.
------------------------
struct V {
int a;
int b;
}
V f()
{
int q = 0;
int unused;
int unused2;
return V(q, 0);
}
void main()
{
const w = f().b;
}
Comment #2 by witold.baryluk+d — 2007-05-19T08:27:07Z
Another example or problem with struct and char literals in CTFE:
import std.stdio;
struct Col2Spec {
char[] type;
char[] name;
}
char[] f() {
char[] id = "x", id2 = "y";
Col2Spec a = Col2Spec(id,"a"); // error in CTFE
// Col2Spec a = Col2Spec("b",id2); // works
int i = 2;
assert(i - i, "Should be 'a', is " ~ a.name); // output, line: 13
return "ret";
}
void main() {
const static char[] w = f(); // line: 18
// f(); // works
}
// sb.d(18): Error: cannot evaluate f() at compile time