Plan 9's abort causes an access fault, causing the current process to enter the `Broken' state. The process can then be inspected by a debugger. Pretty elegant.
http://plan9.bell-labs.com/sources/plan9/sys/src/libc/9sys/a...
http://plan9.bell-labs.com/sources/plan9/sys/src/libc/9sys/a...
The spec says it equals NULL, which, too, is not necessarily 0x0.
On a more prosaic note, perhaps
for(;;)
*(int *)0;
generates a compiler warning that the programmer wanted to avoid. *(int *)0;
and:- for(;;)
*(int *)0;
So the first bit of code does nothing, and the second slips off into an infinite loop.I suspect that treating expressions that demonstrably lack side effects (other than the intended segfault here of course) as statements is undefined, and hence these are getting optimised out (even with -O0).
Clearly with:-
while(*(int *)0)
The expression is being evaluated and is therefore not elided, I guess the choice of while is to 'be cute' as others have suggested, and I guess the world is sane in plan 9 and 0 is readable so you can't get a situation where it escapes the loop. Perhaps there is a deeper reason here that I am missing, however.0 cast as a pointer is defined by the spec to always be the NULL pointer, which on such architectures would have a value other than 0x0 and not point anywhere addressable.