A
Andrew Smallshaw
Many implementations currently allow dereferencing a null pointer (at
least for reading) to access the data at address 0. Although no C
object can be located there, the data might still be interesting. Other
implementations trap when a null pointer is dereferenced (at least for
writing) and some programs depend on that behaviour to produce a trap.
That was precisely the reason that came to mind for me: deliberately
triggering an exception as a kind of "hardcoded breakpoint" to
trace through interesting areas of code without the need to set
large numbers of breakpoints manually in the debugger. There are
cleaner ways of doing this of course, such as assertions, but not
all platforms trigger a breakpoint on a failed assert(). It seems
to me that (in C at least) attempting to second guess what the
programmer may or may not want to do is generally a bad idea.