Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!apple!vsi1!daver!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.lang.c Subject: Re: I'm confused (Re: What C compilers have non-zero null pointers?) Message-ID: <26AF37E8.36EE@tct.uucp> Date: 26 Jul 90 18:35:19 GMT References: <30820@eerie.acsu.Buffalo.EDU> <9007201132.AA06954@edison.CHO.GE.COM> <1990Jul23.122612.20886@athena.mit.edu> Organization: ComDev/TCT, Sarasota, FL Lines: 29 According to scs@adam.mit.edu (Steve Summit): >rja writes: >>[NULL] is broken on several widely >>used C compilers for the Intel segmented architecture. > >It wouldn't hurt if you named names. I think he's talking about Turbo C and Microsoft C, which of course are not broken (with respect to NULL, anyway). In a portable program, any pointer may be compared for EQUALITY with NULL. Microsoft and Borland handle this case correctly. However, in a portable program, no pointer may be compared for RELATIVE MAGNITUDE with NULL. Attempting to do so under Microsoft or Turbo C will result in a comparison of the segment offset, but not the segment selector. Why is this done? Efficiency. Is it broken? No. Read on... The ANSI C standard does not guarantee that comparisons of magnitude with NULL will do anything meaningful. Comparisons of magnitude are only valid within a single object (structure or array), and by definition, NULL cannot point to any object. By coincidence, comparisons of magnitude with NULL work on many architectures. The '286 isn't one of them. -- Chip Salzenberg at ComDev/TCT ,