Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!munnari.oz.au!csc!csc3!anucsd!bdm From: bdm@anucsd.oz (Brendan McKay) Newsgroups: comp.std.c Subject: Two questions about pointers Message-ID: <1989Oct18.121516.10695@anucsd.oz> Date: 18 Oct 89 12:15:16 GMT Organization: Comp Sci, Australian National Uni, Canberra Lines: 28 Here are two questions about the semantics of pointers, as defined by the proposed ANSI standard. (1) Is it true that two pointers of the same type which point to the same object must compare equal? (2) If two pointers of the same type compare equal, and each is cast to a second pointer type, must the results compare equal? The answer to both questions is "yes" in all implementations I can think of, and will probably be "yes" in any implementation in which pointers are represented just as machine addresses without meta-information. The question is whether the proposed standard actually requires such behaviour. One can design weird pointer implementations which obey all the rules relating to pointers, as far as I can see, but which do not have one or both of these properties. I can e-mail an example to anyone interested. Note that Section 3.3.9 does not answer Question (1), at least not directly. It gives the implication around the other way (equal pointers must point to the same object). Question (2) is of particular interest if the second type is void*. If I am correct in thinking that these properties are not required by the standard, was that intentional, or was it an oversight? If I'm not correct, please be gentle. Brendan McKay, bdm@anucsd.oz or bdm@anucsd.oz.au