What machines core dump on deref of NULL?

Jonathan I. Kamens jik at athena.mit.edu
Fri Jun 29 23:23:04 AEST 1990


In article <412 at minya.UUCP>, jc at minya.UUCP (John Chambers) writes:
|> Hey, wait just a minute here.  I can't let such an erroneous error go
|> unchallenged!  Dereferencing a null pointer is quite definitely *not*
|> an error, bug, mistake, or any other pejorative, in a great many sorts
|> of applications.
|> 
|> The trouble with generalizing to all C code is that C outgrew Unix
|> about a decade ago.

  From K&R Second Edition, Page 102: "C guarantees that zero is never a
valid address for data, so a return value of zero can be used to signal
an abnormal event, in this case, no space."  ANSI C is a lot newer than
"about a decade ago." 

  If you use a compiler that allows 0 to be a reference to valid data,
then your compiler is non-standard.  There may be situations (such as
the one you described in your posting) in which such a non-standard
configuration is desired, but just because it's desired doesn't mean
it's valid standard C.

  It would seem to me that a simpler solution to the embedded processor
problem than requiring a non-standard C compiler in order to write code
for one would be to not have any physical memory at address 0, or to put
program memory there (since, unless the program is self-modifying, it
should never have to access its own memory, excluding perhaps function
pointers).

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.wizards mailing list