Thread overview
predefined version for "nogc" option
Sep 02
Sep 03
Sep 03
Sep 05
Sep 05
September 02
I need function that do one thing if GC enabled and other when disabled.

I filled issue about it, but maybe u can show some trick:
how to determine in code that "nogc" is enabled?

LDC supports command option:
-nogc = Do not allow code that generates implicit garbage collector calls.

but I cannot find corresponding predefined version in

need to add version LDC_nogc or D_nogc.
the one should be enabled for -betterC too.

September 03
__traits(compiles,new int)
September 03
On Tuesday, 3 September 2019 at 08:18:13 UTC, Kagamin wrote:
> __traits(compiles,new int)

it doesn't work

2 version of runtime exists:
- at compiletime when compiler/ctfe can use all features.
- and app runtime when constraints can exist such as no GC, no exceptions..

what exactly __traits(compiles) checks "can this code compile without any conditions?" ?
maybe need another trait "rtcompiles" to take into account current options/conditions?
September 05
At least

void f() @nogc
    static assert(__traits(compiles,new int));

September 05
On Thursday, 5 September 2019 at 08:02:15 UTC, Kagamin wrote:
> At least
> void f() @nogc
> {
>     static assert(__traits(compiles,new int));
> }
> fails

u know that u haven't gc in blocks @nogc.

try to run
> static assert( __traits( compiles, new int));
> extern(C) int main() { return 0; }
for DMD/LDC:-betterC or LDC:-nogc

__traits( compiles, new int) is true.
but shouldn't cuz when u use "new int" in code u will get error - module compiled for noGC.
(probably we have issue here with __traits)
and I don't need error, I am trying to find workaround, so I need some flag/version to choose right code for version with GC and another.