if(p)

Henry Spencer henry at utzoo.UUCP
Tue Nov 5 11:04:41 AEST 1985


> Um, treating an all-0 value as a pointer? But what operation do you do on
> pointers apart from dereferencing that could be construed as doing something
> with a *pointer* as opposed to doing something with a *variable*? ...

The distinction you are drawing is not portable.  You are assuming that
one can treat something as a variable without implying a type.  This is
not necessarily true.  It is conceivable, for example, that pointers are
not the same size as any of the integer types, in which case manipulating
them using integer instructions isn't possible.	 Or, as in the case John
Bruner explained (which is the one I was thinking of), there are good
reasons for *wanting* to use the instructions which know that the data
item is a pointer.  For example, I think on his machine it's not possible
to load something into an address register without getting it checked for
validity as a pointer, and doing things like pointer assignments while
never using the address registers is awkward.

No, you don't need an architecture radically unsuited to C to get conditions
where all-0 is unsuitable as the NULL pointer.  A slightly odd architecture
with a bit more knowledge of datatypes than the usual ibm360/pdp11 clone
is all it takes.  Yes, software portability to and from such machines is
meaningful and useful.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list