Referencing NULL pointers

Guy Harris guy at auspex.auspex.com
Wed Jul 12 05:10:05 AEST 1989


>I would say that the code is valid.

And you'd be wrong in saying so.  The ANSI C standard makes it quite
clear that dereferencing null pointers is a no-no, and K&R never said it
was valid.

For reasons cited in my posting, even if it *doesn't* cause a
segmentation violation, the behavior isn't guaranteed; on such systems,
you'd be most likely to get whatever stuff was lying around location 0
in your address space, and that can be almost anything. 

"valid" doesn't mean "anything you can get away with without a core
dump".



More information about the Comp.unix.wizards mailing list