What machines core dump on deref of NULL?

Bob Goudreau goudreau at larrybud.rtp.dg.com
Tue Jul 3 01:38:37 AEST 1990


In article <413 at minya.UUCP>, jc at minya.UUCP (John Chambers) writes:
> > 
> > We should NOT make engineering decisions based on
> > perceived blame.  Dereferencing null pointers is
> > *illegal* and *non-portable*.
> 
> Beg to differ, but C is widely used for writing embedded code (i.e.,
> code that runs standalone on a board with a processor, some memory,
> and generally some other interesting hardware).  The hardware always
> insists that something particular be kept in low memory.  The code
> must be able to read (and often write) location zero, or it can't 
> possibly do its job correctly.  This is as true of the typical Unix 
> kernel as it is of any other system.  If a C compiler doesn't allow
> dereferencing a null pointer, the applications that must do so due
> to the hardware's requirements are rather crippled, or must be coded 
> partially in some other language.
> 
> True, dereferencing a zero pointer is usually incorrect.  But "usually" 
> and "always" aren't even nearly synonyms.  Until we can get the hardware 
> designers to stop using address zero, we are stuck with the situation.

You are confusing the C language's null pointer with a machine address
whose bit pattern happens to be all zeros.  These two concepts are *not*
one and the same.  For a thorough explanation of the null pointer, go
read comp.lang.c's FAQ articles.

------------------------------------------------------------------------
Bob Goudreau				+1 919 248 6231
Data General Corporation
62 Alexander Drive			goudreau at dg-rtp.dg.com
Research Triangle Park, NC  27709	...!mcnc!rti!xyzzy!goudreau
USA



More information about the Comp.unix.wizards mailing list