CTFE is getting there

bearophile bearophileHUGS at lycos.com
Sat Nov 12 15:38:58 PST 2011


With the recent rounds of improvements to the compile-time evaluation, mostly from Don, CTFE is now able to run a significant percentage of D code. Some problems left:


int foo1() {
    enum int[] array = [1];
    return 1;
}
int foo2() { // like map
    struct Bar {
        this(int x) {}
    }
    Bar(1);
    return 2;
}
int foo3() { // like std.math.poly
    version (D_InlineAsm_X86) {
        asm {
            nop;
        }
    } else {
        // fallback code here
    }
    return 3;
}
void main() {
    enum int f1 = foo1();
    enum int f2 = foo2();
    enum int f3 = foo3();
}



Another problem that I have not fully reduced yet:
http://d.puremagic.com/issues/show_bug.cgi?id=6934


I have recently asked regarding foo3 in D.learn. It's a bit sad case, because there are some functions like std.math.poly that define usable fallback code, but CTFE defines D_InlineAsm_X86 so it tries to run the assembly code, and fails.

Bye,
bearophile


More information about the Digitalmars-d mailing list