swap doesn't work in CTFE?

Johann MacDonagh johann.macdonagh..no at spam..gmail.com
Mon Jul 4 09:15:16 PDT 2011


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.


More information about the Digitalmars-d-learn mailing list