www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - -nogc command line switch

reply Jack Applegame <japplegame gmail.com> writes:
-nogc switch doesn't allow compile time GC allocations:

template foo(uint N) {
	import std.conv : to;
	static if(N == 0) enum foo = "";
	else enum foo = N.to!string ~ foo!(N - 1);
}

pragma(msg, foo!10);


Error: No implicit garbage collector calls allowed with -nogc 
option enabled: `_d_arrayappendcTX`


Is it a bug?
Nov 05 2018
parent kinke <noone nowhere.com> writes:
On Monday, 5 November 2018 at 18:47:42 UTC, Jack Applegame wrote:
 Is it a bug?
I guess it can be seen as a bug, or just as a limitation of that apparently LDC-specific feature. IIRC, it just checks for calls to functions in a hardcoded list of GC-allocating functions (may not be up-to-date, as it's probably not widely used) and apparently doesn't differentiate between runtime and compile-time interpretation.
Nov 05 2018