Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ncar!umigw!steve From: steve@umigw.MIAMI.EDU (steve emmerson) Newsgroups: comp.lang.c Subject: pointer comparison question Summary: is this guaranteed or not? Message-ID: <185@umigw.MIAMI.EDU> Date: 14 Nov 88 00:58:26 GMT Reply-To: steve@umigw.miami.edu (steve emmerson) Followup-To: comp.lang.c Distribution: na Organization: University of Miami Lines: 29 Sorry to bring this up again, but I didn't get no satisfaction last time (i.e. no one responded to the main point in question). The question is this: is the following expression guaranteed to return true if and only if "TestPtr" points within the array: static struct foo array[NUM]; static struct foo BegPtr = array[0]; static struct foo BegPtr = array[NUM-1]; extern struct foo *TestPtr; /* could also come from a function call */ TestPtr >= BegPtr && TestPtr <= EndPtr; /* guaranteed to do what I want? */ Or is it "implementation defined" or "undefined". Note the "if and only if" condition, which means that if the expression is false, then "TestPtr" *must* point "outside" the array. I know about pointer comparisons only being guaranteed for pointers into the same array. What I don't know is what that means for the above expression. P.S. This is a contrived problem. I know the alternatives. -- Steve Emmerson Inet: steve@umigw.miami.edu [128.116.10.1] SPAN: miami::emmerson (host 3074::) emmerson%miami.span@star.stanford.edu UUCP: ...!ncar!umigw!steve emmerson%miami.span@vlsi.jpl.nasa.gov "Computers are like God in the Old Testament: lots of rules and no mercy"