Although CTFE supports ref parameters, swap doesn't appear to work. This casues dmd to segfault in 2.053 and the current dmd master.

import std.algorithm;
import std.stdio;

string ctfeRef(ref string a, ref string b)
{
        return a;
}

string ctfeSort()
{
    auto x = [ "a", "c", "b" ];
    swap(x[1], x[0]);           // This is the problem here
    return ctfeRef(x[1], x[0]);
}

void main()
{
    enum xx = ctfeSort();
    writeln(xx);
}

This means things like sort won't work in CTFE. Does anyone know if this is a known bug? My searching didn't bring anything up.

Reply via email to