assert(false) in release == splinter in eye
Vladimir Panteleev
vladimir at thecybershadow.net
Sun Oct 10 23:01:16 PDT 2010
On Mon, 11 Oct 2010 00:22:38 +0300, Tomek Sowiński <just at ask.me> wrote:
> BTW, does anybody know the reason for the assert(0) infernal syntax?
From http://www.digitalmars.com/d/2.0/expression.html#AssertExpression:
"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."
Sometimes it's useful to add an assert(0) at the end of a function which
should always return at other points, but the compiler can't know that.
--
Best regards,
Vladimir mailto:vladimir at thecybershadow.net
More information about the Digitalmars-d
mailing list