From -886853881988970096
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-12-01 05:19:14 PST
Newsgroups: comp.std.c++
Path: sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinen
From: sakkinen@jyu.fi (Markku Sakkinen)
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <1992Dec1.072440.824@jyu.fi>
Organization: University of Jyvaskyla, Finland
References: <1992Nov4.080805.13496@jyu.fi> <1992Nov27.091056.3895@jyu.fi> <1992Nov30.195202.14370@ucc.su.OZ.AU>
Date: Tue, 1 Dec 1992 07:24:40 GMT
Lines: 51

In article <1992Nov30.195202.14370@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>In article <1992Nov27.091056.3895@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
>>> ...
>>> I have difficulty to imagine any useful programming idioms that would
>>> depend on either A, B, or C (or on the exact way in which a particular
>>> implementation makes pointers not be totally ordered),
>>> but you speak about tons of legal programs that would become illegal.
>>> Could you give a small example?
>>> ...
>	On the 80x86 machines, with segmented architectures,
>one might define == and != to comparte BOTH the offset and segment
>(as required by the ARM and the extra rule you suggested ought to
>have been in the ARM).
>
>	However, the < operator might be implemented to compare
>ONLY the offset part. This is legal because it is 'implementation
>defined'. One could create TWO arrays in different segments,
>and use < to compare relative positions of pointers into
>these different arrays.
>
>Such an implementation dependent routine would fail 
>if the definition of < were
>changed, including if it were changed to require a total order.
>
>This is not a very practical example, Jim can provide a better one
>perhaps. 

Is this what you mean?
	if (p == q) ... // the same object (assuming the mentioned correction
			// to the rules)
	else if (p < q) ... // in the same segment
	else if (p > q) ... // in the same segment
	else ... // the objects must be in different segments!
If some compilers really work like this (i.e. neither p==q, p<q, nor p>q holds when
p and q point to different segments, it is indeed possible to write code that would
behave differently if total order for pointers were required.

I still cannot believe Jim Adcock's claim that this would affect "tons of useful
software".  In what circumstances would one normally be interested about the segments
in which the objects lie?  The above idiom does not help to test whether the pointers
point into different _arrays_, since there can be more than one array in each segment.

----------------------------------------------------------------------
Markku Sakkinen (sakkinen@jytko.jyu.fi)
       SAKKINEN@FINJYU.bitnet (alternative network address)
Department of Computer Science and Information Systems
University of Jyvaskyla (a's with umlauts)
PL 35
SF-40351 Jyvaskyla (umlauts again)
Finland
----------------------------------------------------------------------


