In article <cm**********@oravannahka.helsinki.fi>,
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
Mark McIntyre <ma**********@spamcop.net> scribbled the following: On 1 Nov 2004 18:55:05 GMT, in comp.lang.c , Joona I Palaste
<pa*****@cc.helsinki.fi> wrote:All the ANSI standard specifies in this
regard is that if two strings have different contents, an == comparison
must return 0.
Only by coincidence, since the values of the pointers to the two will more
or less have be different. I guess its possible to concieve of an
implementation or mechanism where this would not be true.
If it is, *I'd* be glad to hear of it. Wouldn't this require memory
behaving differently depending on which pointer it's accessed through?
Not allowed to happen. If two pointers compare equal, following them
will give you the same object, which has to have the same value whichever
pointer you use to get at it.
Note that this only applies to equality conversions - it's possible to
have two different pointers (to nonidentical strings, f'rexample) such
that ptr1<ptr2 and ptr2<ptr1 both evaluate to false (which if pointers
were well-ordered would imply that they were equal).
(This can happen in a fully segmented memory model where only the offsets
into the segment are used for inequality comparisons, which is valid
since pointer inequality comparisons are only defined on pointers into
the same object or array. Comparing for equal or not-equal doesn't have
this constraint and would be required to check both segment and offset,
coming back with not-equal in this case.)
dave
--
Dave Vandervies
dj******@csclub.uwaterloo.ca
Now, obviously I've picked a terrible example, ... But if I picked something
complicated like error-diffusion, it would be... well... complicated.
--Arthur J. O'Dwyer in comp.programming