references to dereferenced null pointers

John R. MacMillan john at hcr.uucp
Fri Mar 16 04:49:03 AEST 1990


Karl Heuer <karl at haddock.ima.isc.com> writes:
|>There is absolutely nothing wrong with having a pointer representation in
|>which the bit pattern for a null pointer is not all zeros... except that
|>there are a lot of old, badly-written programs which will break.  Thus my
|>earlier comment that it is valid but unwise.
|
|Note that "p = 0", "p == 0", "!p", "char *f() { return 0; }" are *not*
|examples of such badly-written code; they may be bad style, but the compiler
|is required to generate correct code involving a true null pointer.  The only
|"dangerous" context (other than hacking with unions and such) is when a null
|pointer constant is being passed as an argument to a function.

``Zeroing out'' pointers with memset, bzero, or calloc is another
all-too-common problem.
-- 
John R. MacMillan	| "All the best freaks are here; please stop staring
HCR Corporation		|  at me."
{utzoo,utcsri}!hcr!john	| -- Marillion



More information about the Comp.lang.c mailing list