Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!novavax!proxftl!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.std.c Subject: Re: pointer comparisons in dpANS C Message-ID: <114@twwells.uucp> Date: 23 Oct 88 18:50:03 GMT References: <1988Oct11.143728.28627@gpu.utcs.toronto.edu> <6777@chinet.chi.il.us> <8696@smoke.ARPA> <14061@mimsy.UUCP> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 24 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <14061@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: : [followups redirected to comp.std.c] : In article <8696@smoke.ARPA> gwyn@smoke.ARPA (Doug Gwyn) writes: : >The key is that you are allowed to portably compare pointers only in two : >cases: at least one pointer is a null pointer, or both pointers are : >pointers into the same object. This means that the fact that p1==p2 for : >pointers to distinct objects is not a problem, since such comparison is : >"undefined". ... : : This point (which is true) makes me wonder about something. Consider : a program which allocates object memory with `malloc'. Each object has : pointers to other objects, but does not have backpointers---e.g., : a singly linked list. Now we have a removal routine: Guys, you are going to have to convince me of this. From everything I see, two pointers are not allowed to compare equal *unless* they point to the same object. Section 3.3.9 is very clear on this point. It is only for tests other than equality or nonequality that the pointers must point within the same object. --- Bill {uunet|novavax}!proxftl!twwells!bill