Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.std.c Subject: Re: Two questions about pointers Message-ID: <1989Oct21.005145.23598@twwells.com> Date: 21 Oct 89 00:51:45 GMT References: <1989Oct18.121516.10695@anucsd.oz> Organization: None, Ft. Lauderdale, FL Lines: 28 In article <1989Oct18.121516.10695@anucsd.oz> bdm@anucsd.oz (Brendan McKay) writes: : (1) Is it true that two pointers of the same type which point to the : same object must compare equal? Yes. See 3.3.9. Read further before disagreeing. : (2) If two pointers of the same type compare equal, and each is cast : to a second pointer type, must the results compare equal? If there is an object there of that new type, yes. (E.g., unions.) Or, if both pointers were originally of the new type, yes. As near as I can tell, converting two pointers to a void* and then testing for equality does not have to work, unless both were void*'s to begin with. : 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*. You either have an old draft or you have not read yours carefully. From the May 88 draft: "If two pointers point to the same object or function, they compare equal." --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com