🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #43

Re: Zero-length structures and pointer comparisons

#43
From: Markku Sakkinen
Date: Wed, 04 Nov 1992 08:08
77 lines
3836 bytes
In article <1992Oct30.003946.10484@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
>In article <1992Oct28.184135.25475@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>|	...
>|If a total ordering was required, programs utilising
>|this requirement would be portable. 
>
>Nope.  They would only become portable if this was the last non-portability
>in that program -- hardly likely.
>
>On the converse side, tons of previously legal but not *strictly* portable 
>programs would now become illegal.
>
>Thus your trade-off would represent a major lose:  Lots of legal programs
>become busted in exchange for making an unlikely few programs portable.
> ...

I would first like to return to a much more important, related problem,
which somebody brought up here rather recently.
Namely, there is nothing in the ARM explicitly saying that
p == q  might not yield 1 even when p and q are pointing at two different
objects.  This hole makes e.g. some standard idioms in Stroustrup's books
implementation dependent.

(If p has type A* and q has type B*, where B is derived from A,
then p==q, wherever allowed by access control, will and should of course
yield 1 if q points at a subobject of *p.)

So far, no representative of the ANSI committee has replied
(or I have missed such a posting)!
I am waiting for one of three alternatives:

1) The above picture is wrong:  it can be reasoned from such and such
   paragraphs of the ARM that p==q should imply that *p and *q are the
   same object.

2) The committee is fixing the hole.

3) The situation is indeed as described, and the committee is not planning
   to do anything about it.

Alternative 3 would certainly need some strong arguments,
which I am incapable to imagine.


Suppose that the above problem is settled (alt. 1 or 2).
Then, if there is no total order within pointers of the same type,
essentially one or more of the following holds:

A) '<' is not transitive, i.e. p < q and q < r does not imply p < q.

B) '<' (or rather '<=') is not connective, i.e. there might be p and q
   such that neither p = q, p < q nor q < p holds.

C) All usual relationships between the different relational operators
   need not hold (e.g. p < q does not imply q > p).

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?

BTW, arguments about ANSI C are not always convincing.
C is very much a block-structured assembler, while C++ aspires
to be an object-oriented language, and has much more complex semantics.
Tradeoffs appropriate for C simply need not be wise for C++.
The umbilical cord should finally be cut.

----------------------------------------------------------------------
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
----------------------------------------------------------------------
Technical Details
Message-ID: <1992Nov4.080805.13496@jyu.fi>
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!emory!swrinde!sdd.hp.com!spool.mu.edu!agate!doc.ic.ac.uk!uknet!mcsun!news.funet.fi!network.jyu.fi!sakkinen
References: <1992Oct26.170404.1904@microsoft.com> <1992Oct28.184135.25475@ucc.su.OZ.AU> <1992Oct30.003946.10484@microsoft.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!emory!swrinde!sdd.hp.com!spool.mu.edu!agate!doc.ic.ac.uk!uknet!mcsun!news.funet.fi!network.jyu.fi!sakkinen
From: sakkinen@jyu.fi (Markku Sakkinen)
Newsgroups: comp.std.c++
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <1992Nov4.080805.13496@jyu.fi>
Date: 4 Nov 92 08:08:05 GMT
References: <1992Oct26.170404.1904@microsoft.com> <1992Oct28.184135.25475@ucc.su.OZ.AU> <1992Oct30.003946.10484@microsoft.com>
Organization: University of Jyvaskyla, Finland
Lines: 77