CTFE casts of delegates
Eyal Lotem via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jan 2 23:58:05 PST 2017
Hi,
According to [1], we can use an escape hatch in D to assume
purity or assume @nogc.
We use this escape hatch for 2 purposes:
1) Wrapping standard library functions that forgot the correct
annotations
2) Aborting assertion mechanisms - where we don't care about
@nogc or "pure" in the case that we abort the program.
-----
However, a big drawback of this escape hatch is that if it is
ever used (even very indirectly) in the context of CTFE, it
yields a DMD error:
Error: pointer cast from void function() @safe to void function()
@nogc @safe is not supported at compile time
-----
Losing the ability to call this assertion mechanism from any
function that is used in CTFE context is very problematic.
How can I work around this issue?
Should it be considered a DMD bug? Is there any reason for
attribute-only delegate/function casts in CTFEe to be disallowed?
[1] http://klickverbot.at/blog/2012/05/purity-in-d/
More information about the Digitalmars-d
mailing list