checkedint call removal

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 28 14:17:46 PDT 2014


"bearophile"  wrote in message news:tijfjtihtubozpjojgvl at forum.dlang.org...

> > One murky area is that assert(0) is currently used to mean both 
> > 'unreachable' and 'unimplemented'.  It's unclear what the compiler is 
> > allowed to do with an assert(0) in release mode.
>
> I'd still like to have a halt() in D, and have assert(0) with the same 
> semantics of the other asserts. In many cases when you have a different 
> feature it's good to also give it a different name.

Turns out it's not so murky according to the spec:

The expression assert(0) is a special case; it signifies that it is 
unreachable code. Either AssertError is thrown at runtime if it is 
reachable, or the execution is halted (on the x86 processor, a HLT 
instruction can be used to halt execution). The optimization and code 
generation phases of compilation may assume that it is unreachable code.

I'm quite happy to accept that using assert(0) as halt can only be relied on 
in non-release mode. 



More information about the Digitalmars-d mailing list