From -4182991417879992766
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-10-18 20:04:08 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: <1992Oct19.055511.18826@jyu.fi>
Organization: University of Jyvaskyla, Finland
References: <1992Sep10.094957.23588@jyu.fi> <1992Oct16.234851.28948@microsoft.com> <23915@alice.att.com>
Date: Mon, 19 Oct 1992 05:55:11 GMT
Lines: 48

In article <23915@alice.att.com> ark@alice.UUCP () writes:
>In article <1992Oct16.234851.28948@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
>
>> But in any case, at least my PC compiler (Large Model)
>> performs == and != comparisons based both on the segment and offset parts.
>> Its the ordered comparisons > < >= <= where only the offset part is compared.
>> Thus == != work for all ptrs.  > < >= <= only work within an array.
>
>> Which is as it should be.
>
>This is far from clear.
>
>For example, if a type T has a < operator defined that is actually a strong
>total order relation, that makes it possible to store T objects efficiently
>in a variety of order-based data structures such as M,N-trees, etc.
>There are many applications for such structures.  For example, one might make
>the constructor and destructor for class T use such a structure to keep
>track of all the T objects in the universe, and so on.

Sorry, there is a misunderstanding here.
The discussion in this thread (see subject line) has been about _pointer_
comparisons all the time.  Comparison of object values is another story
altogether.

Another aspect of the original problem:
Given two pointer values (of the same type), it is acceptable that
their ordered comparison is not always sensible (or it is implementation
dependent).  However, there does not even exist any standard way to test
_whether_ the comparison is valid (i.e., if the pointers point at elements
of the same array or at members of the same object).
That is a defect.

While we are at it, I would like to hear if the standardisation committee
has completed the requirement of the ARM (p. 74): "Two pointers to the
same object compare equal." with "Two pointers of the same type to different
objects compare inequal." or something similar.
(The qualification 'of the same type' is necessary because of base class
vs. derived class pointers.)

----------------------------------------------------------------------
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
----------------------------------------------------------------------


