Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbosgd!ucbvax!ucbcad!faustus From: faustus@ucbcad.BERKELEY.EDU (Wayne A. Christopher) Newsgroups: net.lang.c Subject: Re: ANSI C Message-ID: <971@ucbcad.BERKELEY.EDU> Date: Mon, 18-Aug-86 14:27:27 EDT Article-I.D.: ucbcad.971 Posted: Mon Aug 18 14:27:27 1986 Date-Received: Tue, 19-Aug-86 04:25:35 EDT References: <86900009@haddock> <86900017@haddock> Organization: CAD Group, U.C. Berkeley Lines: 30 If there is a compiler that defines NULL as something other than an all-0 bit pattern, I certainly hope that "if (!p)" will do the right thing, otherwise most existing code won't work. But this should never be a real problem, since all the loader has to do is guarantee that nothing valid will ever have an address that corresponds to the conversion of integer 0 to a pointer. There are no architectural considerations involved -- if there are tag bits, etc, just let them be all 0 -- the pointer should never be referenced anyway, so who cares what the tag bits are. In article <86900017@haddock>, karl@haddock writes: > > "Fixing" it the other way, by having any integral expression with the value > > 0 convert to a null pointer, would ... surprise some code that does want to > > grab a pointer value [as int] and then stuff the value back into the > > pointer, if a pointer value of all zero bits is a valid pointer. You can always use a union, or cast a pointer to the needed value -- these tricks are used for things like dissecting floating point numbers. > Hmm, there's a similar problem without the full-check conversion. If the > constant zero is converted into a null pointer constant, and zero is a valid > address, and something of interest is at that absolute address, how do I > reference it? If there is something of interest at location 0 then you should complain to whomever put it there. It's a very good idea to make null pointer references cause a fault -- this catches lots of nasty bugs. If this isn't the case on your machine, you can still use the tricks mentioned above. Wayne