On Phobos GC hunt
Daniel Murphy via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 20 06:16:37 PDT 2014
"Martin Nowak" wrote in message news:m1udcn$s35$1 at digitalmars.com...
> On 10/08/2014 10:01 PM, Andrei Alexandrescu wrote:
> >
> > That's a bummer. Can we get the compiler to remove the "if (__ctfe)"
> > code after semantic checking?
> >
> > Andrei
>
> It seems that __ctfe is treated as constant in the backend.
> > At least there is no asm code generated for these examples (even without
> -O).
>
> void main()
> {
> import std.stdio;
> if (__ctfe)
> writeln("foo");
> }
>
> int main() { return __ctfe ? 1 : 0; }
__ctfe is passed to the backend as 'false', and even with -O the basic
optimizations will strip it as dead code. So it is removed after semantic
checking, but that doesn't help as semantic checking includes @nogc
checking.
More information about the Digitalmars-d
mailing list