[Issue 1204] segfault using struct in CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 19 06:27:08 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1204





------- Comment #2 from baryluk at mpi.int.pl  2007-05-19 08:27 -------
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


-- 



More information about the Digitalmars-d-bugs mailing list