Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Creating pointer with all bits 0 (was: Referencing NULL pointers) Message-ID: <1989Sep6.164125.20612@utzoo.uucp> Organization: U of Toronto Zoology References: <1989Aug31.052756.18524@sq.sq.com> <2030@se-sd.NCR.COM> <1989Sep6.052228.17374@algor2.algorists.com> Date: Wed, 6 Sep 89 16:41:25 GMT In article <1989Sep6.052228.17374@algor2.algorists.com> jeffrey@algor2.UUCP (Jeffrey Kegler) writes: >Question: Is an implementation whose null pointer is the same as the >result of some integer-to-pointer cast conforming? Apparently not, >since 3.2.2.3 states, "... a null pointer is guaranteed to compare >unequal to a pointer to any object or function." Does not follow. There is nothing that says that the result of casting an integer to a pointer will be a pointer to an object. It is entirely legitimate for some integers to become null pointers when cast. >If I am correct, this could cause problems. It is not hard to imagine >an implementation where every possible pointer bit pattern is a valid >physical address. No pattern would remain for the null pointer... The pdp11, the very first machine on which C was implemented, had this property. The solution was to use a software convention in which no variable was ever put at location 0, and any programmer who *really* wanted to use something at 0 was breaking the rules and was on his own. I see no reason why the same approach won't work for ANSI C. -- V7 /bin/mail source: 554 lines.| Henry Spencer at U of Toronto Zoology 1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu