Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: Pointer comparison and Portability Message-ID: <13651@sun.uucp> Date: Thu, 19-Feb-87 14:54:38 EST Article-I.D.: sun.13651 Posted: Thu Feb 19 14:54:38 1987 Date-Received: Fri, 20-Feb-87 22:12:40 EST References: <4537@brl-adm.ARPA> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Organization: Sun Microsystems, Mountain View Lines: 32 >Unfortunately, the Intel 8086 series provides another counter example. >On this machine, address are in the form of segment and offset. The >Actual Address is 16*segment + offset. Yes, but *if* you happen to construct two different long pointers that point to the same address, that's just like double-mapping a location with an MMU. >So, if two pointers compare equal, they definately point at the same >object. However, the converse is not true. Two pointers that do not >compare equal do NOT (necessarily) point at different objects. Yes, but this is an escape hatch for the benefit of e.g. systems that have to do double mapping. It is *not* intended to render comparison of pointers for equality useless except when comparing pointers to elements in the same array. >Seems like when K & R says that pointer comparison is undefined except >when the two are pointers to the same array, it should be taken to mean >exactly that for all operators, including == and !=. Yes, but the ANSI C standard explicitly separates pointer comparison for (in)equality from relational comparison on pointers. Anybody who tried to sell *me* a C implementation where the same object had two addresses *except* when something was explicitly doubly mapped, or in similarly unusual cases (e.g. an 808[68] with no memory mapping, where a segment, treated as a full 64KB segment, overlapped another segment, but where the segment *really* isn't long enough to overlap it) - i.e., an implementation where pointer equality wasn't equivalent to object equality, except in some *very* specialized and *explicitly*-documented cases - would be shown the door rather quickly.