On 2013-11-18 12:03, Jonathan M Davis wrote:
assert(0) is intended specifically for use in cases where a line is supposed to
be unreachable, and it wouldn't make any sense to use it in any other case,
because assertion failures are intended to kill the program, and assert(0)
always fails. It happens that it throws an AssertError in non-release mode in
order to give you better debug information on failure, and it's a HLT
instruction in release, but in either case, it's intended to be unreachable
code.
The spec really should be updated to make it clear that when assertions are
compiled in, assert(0) throws an AssertError and that when assertions are
supposed to be compiled out, it becomes a HLT instruction. And if need be, we
can update the spec to require that try-catches be compiled out when
assertions are compiled out, and the catch's body only contains an assert(0).
Does all architectures support the HLT instruction or equivalent? The
spec explicitly says HLT is used on x86.
--
/Jacob Carlborg