Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!pacbell.com!tandem!netcom!ergo From: ergo@netcom.UUCP (Isaac Rabinovitch) Newsgroups: comp.lang.c Subject: Re: What C compilers have non-zero null pointers? Message-ID: <12288@netcom.UUCP> Date: 17 Jul 90 19:38:10 GMT References: <9007161750.AA00664@edison.CHO.GE.COM> Organization: UESPA Lines: 35 In <9007161750.AA00664@edison.CHO.GE.COM> rja@edison.cho.ge.com (rja) writes: >I used to use a compiler for MSDOS and the 80x86 cpus >whose NULL pointer was F000:0000 hex when examined via >a debugger. It of course did compile fine as long as one >used sense and compared pointers to NULL rather than >a constant of zero... True. But what the "NULL should always be 0" diehards want is not to write (for example) for (ptr = fist; ptr != 0; ptr = ptr->next) in which 0 should probably be #DEFINED anyway, but rather for (ptr = first; ptr ; ptr = ptr->next) which produces tighter code and (most important of all) looks spiffier. It has the elegance of expression old C hands crave. >Compilers where NULL isn't represented as all zero bits >just aren't that uncommon. My '78 K&R says that assigning 0 to a pointer is (or was) guarranteed to produce a NULL, even on compilers that didn't like other integer-to-pointer assignments. But, interestingly, they did *not* guarantee, even then, the reverse! -- ergo@netcom.uucp Isaac Rabinovitch atina!pyramid!apple!netcom!ergo Silicon Valley, CA uunet!mimsy!ames!claris!netcom!ergo "I hate quotations. Tell me what you know!" -- Ralph Waldo Emerson