pointer sizes, was: Re: What does char **ch mean?

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Fri May 17 19:00:11 AEST 1991


In article <1991May15.234259.2613 at research.canon.oz.au>, andy at research.canon.oz.au (Andy Newman) writes:
> I remember great concern by one compiler writer over what value should be
> stored for null pointers [on transputers].
> The person used 0 so as not to break all the source
> that assumes that null pointers are 0. This threw away half the address
> space of the machine (only 2Gb [on a 32 bit machine], what a bummer!).

There is no reason why placing NULL at address 0 should throw away
anything more than one byte of the address space.  C requires a guarantee
that no user-declared variable and no object allocated by malloc() and
friends will ever live at the address which NULL converts to.  It does
_not_ require that NULL convert to the lowest address, and in fact doesn't
define pointer comparison except within (or at the top end of) a single
object.

I've used a 68000-lookalike where user address space was negative, so
that 0 was not in the user's accessible address space.  On that machine,
NULL converted to 0, not to 0x80000000.  That was sensible.

-- 
There is no such thing as a balanced ecology; ecosystems are chaotic.



More information about the Comp.lang.c mailing list