assume, assert, enforce, @safe

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 01:23:44 PDT 2014


"Walter Bright"  wrote in message news:lrbpvj$mih$1 at digitalmars.com...

> 5. assert(0); is equivalent to a halt, and the compiler won't remove it.

This is not the same definition the spec gives.  The spec says assert(0) can 
be treated as unreachable, and the compiler is allowed to optimize 
accordingly.

The difference is that in this code:

if (cond)
    assert(0);

With your above definition cond will be evaluated, while with the spec's 
more powerful definition it may be skipped.



More information about the Digitalmars-d mailing list