Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: I'm confused (Re: What C compilers have non-zero null pointers?) Message-ID: <17095@haddock.ima.isc.com> Date: 16 Jul 90 22:50:37 GMT References: <9007161750.AA00664@edison.CHO.GE.COM> <30820@eerie.acsu.Buffalo.EDU> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 24 In article <30820@eerie.acsu.Buffalo.EDU> chu@acsu.buffalo.edu (john c chu) writes: >In article <9007161750.AA00664@edison.CHO.GE.COM> rja writes: >>[On a machine where the internal representation of a null pointer wasn't 0] >>It of course did compile fine as long as one used sense and compared >>pointers to NULL rather than a constant of zero... If it was compiling C, then it should have worked without that clause. >I thought comparing a pointer to NULL was the same as comparing a pointer to >(a properly cast) zero. In a pointer context, NULL and properly-cast 0 and naked 0 are all equivalent: each refers to the null pointer of the type implied by the context. As an argument to a function not covered by a prototype (this being the only place you can put a null pointer constant and not have a pointer context), a properly-cast NULL and a properly-cast 0 are equivalent. Naked 0 and naked NULL are both incorrect if a null pointer was desired. >I have a feeling most of my questions are probably answered [in the FAQ] Yes, they are. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint