assume, assert, enforce, @safe
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 31 02:13:50 PDT 2014
On 7/31/2014 1:23 AM, Daniel Murphy wrote:
> "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.
It says more than that:
"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."
-- http://dlang.org/expression.html#AssertExpression
More information about the Digitalmars-d
mailing list