CTFE casts of delegates

Eyal Lotem via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 4 23:35:52 PST 2017


On Thursday, 5 January 2017 at 03:05:21 UTC, Jonathan M Davis 
wrote:
> However, since code that legitimately casts a function to alter 
> its attributes should be _very_ rare, it should also be quite 
> rare that the problem even comes up.

It is very rare to have it in code, but the low-level function 
that does this rare thing (custom assertion function) may be very 
frequently called, indirectly.

> So, I would think that making casts for attributes legal during 
> CTFE wouldn't be a problem (though I could be missing 
> something), but at the same time, if someone is actally asking 
> for such a capability, that's very worrisome. That implies that 
> pure and @nogc are not being used correctly and that casts are 
> being used to try and force the compiler into submission, which 
> risks nasty bugs when the compiler is then making assumptions 
> about the code that are wrong thanks to the fact that it was 
> lied to with casts.

Well, I did explain the reason for this cast. An 
aborting-assertion that discontinues execution (hard kill the 
process).

We expect these assertions to never happen. If they do, we don't 
really care about any GC or impure things that they do just 
before terminating the process.

We don't really want *all* code to be marked gc/impure because it 
directly or indirectly uses such assertions.



More information about the Digitalmars-d mailing list