xxxxxxxxxx
import core.stdc.stdio;
// "nogc" shows error for template only when instantiated
S addDot( S )( S s ) if (isSomeString!S) { return s ~ '.'; }
// "nogc" shows error for next line always
//string addDot2( string s ) { return s ~ '.'; }
extern (C) int main()
{
version (D_BetterC) puts("D_BetterC");
version (D_Exceptions) puts("D_Exceptions");
version (D_ModuleInfo) puts("D_ModuleInfo");
version (D_TypeInfo) puts("D_TypeInfo");
static if (__traits( compiles, new int))
"new int".printf;
else
"NO new int".printf;
auto s = "hello world";
version (LDC_nogc) {
// do stuff without GC
//s = addDot( s );
} else {
// code can use GC
//s = addDot( s );
// but option "nogc" is enabled => ERROR
}
return 0;
}