Referencing NULL pointers

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Jul 19 17:10:59 AEST 1989


In article <1759 at cadillac.CAD.MCC.COM> ned%cad at MCC.COM (CME Ned Nowotny) writes:
>However, there are environments where addresses can be represented
>by numeric constants and there really is something important at address 0.

There better not be.  C guarantees that valid object addresses compare
unequal to null pointers, and since a null pointer constant is written
as "0" in C source code, you cannot obtain a valid object address by
casting 0 to the object pointer type.

If this is really a problem for some implementation, then it can arrange
for the "equivalent integer" mapped form of pointers to be essentially
the conventional machine address plus one, or some similar mapping that
keeps 0 from appearing to be a possible valid object address in a C
program.



More information about the Comp.unix.wizards mailing list