The following does not work :
import std.stdio;
class Test
{
this()
{
void* ptr = cast(void*) this;
(*(cast(Test*) ptr)).foo();
}
void foo()
{
writefln("OK");
}
}
int main()
{
auto test = new Test();
return 0;
}
Result : segmentation fault
Could one explain why ?