On 7/26/2016 11:49 PM, Shachar Shemesh wrote:
Current text (after the strange copying corruption):
The expression assert(0) is a special case; it signies 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.

Proposed text:
The expression assert(0) is a special case; it signifies code that should be
unreachable. Either AssertError is thrown at runtime if reached, or the assert
message printed to stderr and execution terminated. The optimization and code
generation phases of the compilation may assume that any code after the
assert(0) is unreachable.

Main differences:
* Some phrasing improvements
* Change the confusing "is unreachable" (so why bother?) with "should be
unreachable", which stresses it's usefulness (and avoids the opinion, expressed
in this thread, that reaching it is UB)
* Remove the recommendation to use HLT on X86, which, as discussed, is plainly
wrong
* Define the behavior symptomatically, allowing both more certainty for
programmers relying on the specs to know what will happen, and for compiler
implementers more freedom to choose the correct way to achieve this effect and
handle resulting bugs.
* Add the requirement that the assert message be printed for assert(0)

Shachar

Thank you. I'd prefer it to say something along the lines that it stops execution at the assert(0) in an implementation-defined manner. This leaves whether messages are printed or not, etc., up to the implementation. I don't think the spec should require more than that (for example, some uses may have no means to print an error message).

Reply via email to