Two questions about pointers
bdm659 at csc.anu.oz
bdm659 at csc.anu.oz
Mon Oct 23 21:04:56 AEST 1989
In article <1989Oct21.005145.23598 at twwells.com>, bill at twwells.com (T. William Wells) writes:
> In article <1989Oct18.121516.10695 at anucsd.oz> bdm at 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.
> 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."
Yes, alas, I have an old draft. This addition places the semantics of
pointers on MUCH firmer footing. Pointers to objects, anyway.
[Can someone please mail me the address for ordering the most recent draft?
And the price. Thanks muchly.]
> : (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.
Yes, that certainly follows from the sentence my copy doesn't have. Thanks.
As far as I can tell, my (old) draft contains absolutely nothing about the
meaning of the equality operators (==, !=) when applied to void* values.
Has that situation changed, or do we still have to guess?
Brendan McKay. bdm at anucsd.oz or bdm at anucsd.oz.au
More information about the Comp.std.c
mailing list