Referencing NULL pointers

CME Ned Nowotny ned at pebbles.cad.mcc.com
Wed Jul 19 06:16:47 AEST 1989


In article <18612 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
=>In article <1759 at cadillac.CAD.MCC.COM> ned at pebbles.cad.mcc.com (CME
=>Ned Nowotny) writes:
=>>The argument over whether or not a C compiler should allow dereferencing
=>>of 0 (NULL) or any other numeric constant purporting to be an address is
=>>unrelated to the question of portability.
=>
=>Actually, it is related, other than in the obvious way (the result of
=>
=>	*(sometype *)(some integer expression)
=>
=>is never portable).  The peculiar thing is that, even on machines
=>where location 0 is addressible and has something there (e.g., restart
=>and interrupt vectors), the expression
=>
=>	*(char *)0
=>
=>might get you something from somewhere other than location 0.

...A good example deleted...


Fair enough.  In fact, I would agree that it is never a good idea to
bind an object to a specific address by assigning a numeric constant
(or integer variable) to a pointer variable within a C program.

It is much better to manipulate objects through symbolic names.  Of
course, this requires a good link editor that includes the ability
to bind symbolic names to absolute addresses.  The System V link editor
did provide this capability, but it is baroque and flawed in other
ways.

Does anyone know what, if anything, UI and OSF are doing about the UNIX
link editors they will be providing?

Ned Nowotny, MCC CAD Program, Box 200195, Austin, TX  78720  Ph: (512) 338-3715
ARPA: ned at mcc.com                   UUCP: ...!cs.utexas.edu!milano!cadillac!ned
-------------------------------------------------------------------------------
"We have ways to make you scream." - Intel advertisement in the June 1989 DDJ.



More information about the Comp.unix.wizards mailing list