Sharing base pointers: c++core discussion
Jim Dehnert
dehnert at baalbek.engr.sgi.com
Thu Jun 17 03:42:59 UTC 1999
For those of you who didn't get it, here's the C++ core discussion
of the issue Jason raised last week:
=================================================================
From: Jason Merrill <jason at cygnus.com>
Date: Tue, 15 Jun 1999 11:20:34 -0700
Message-Id: <199906151820.LAA24561 at yorick.cygnus.com>
To: C++ core language mailing list
Message c++std-core-8101
5.10 - Equality operators [expr.eq]
-1- ... Pointers to objects or functions of the same type (after pointer
conversions) can be compared for equality. Two pointers of the same type
compare equal if and only if they are both null, both point to the same
object or function, or both point one past the end of the same array.
When you consider comparing pointers to void, this seems to suggest that no
two objects can have the same address, depending on your interpretation of
"point to the same object." This would cripple the empty base
optimization.
Seems to me that these rules should only apply to pointers to the type of
the object being pointed to, and that comparing via void* or other
unrelated type should be more flexible.
Jason
=================================================================
From: "William M. Miller" <wmm at fastdial.net>
Date: Tue, 15 Jun 1999 14:30:32 -0400
References: <199906151820.LAA24561 at yorick.cygnus.com>
To: C++ core language mailing list
Message c++std-core-8102
Yet one more problem for this wording. I'll add a note to
issue 73. (The problems already described there are the "object
that happens to be one past the end of an array" and the
"different objects sharing the same space sequentially" issues.)
-- Mike Miller
--
William M. Miller, wmm at setech.com, wmm at fastdial.net
Software Emancipation Technology, Inc., +1 (781) 359-3335
15 Third Ave., Burlington MA 01803 FAX: +1 (781) 359-3399
http://www.setech.com
=================================================================
From: Nathan Myers <ncm at best.com>
Date: Tue, 15 Jun 1999 11:38:45 -0700 (PDT)
To: C++ core language mailing list
Message c++std-core-8103
Jason Merrill, in Message c++std-core-8101, wrote:
> ...
> Seems to me that these rules should only apply to pointers to the type of
> the object being pointed to, and that comparing via void* or other
> unrelated type should be more flexible.
Of course, pointers-to-void don't point at objects.
Nathan Myers
ncm at cantrip.org
=================================================================
From: Greg Comeau <comeau at panix.com>
Date: Tue, 15 Jun 1999 14:52:01 -0400 (EDT)
To: C++ core language mailing list
Message c++std-core-8104
> Of course, pointers-to-void don't point at objects.
They do, but you normally wouldn't call them 'pointers to objects' per se.
- Greg
=================================================================
From: Jason Merrill <jason at cygnus.com>
Date: 15 Jun 1999 12:23:18 -0700
Message-ID: <u97lp5w9nd.fsf at yorick.cygnus.com>
To: C++ core language mailing list
Message c++std-core-8105
...
Perhaps not; [basic.compound] refers to 'pointers to void or objects or
functions'. But in that case, [expr.eq] does not allow you to compare
them; it only allows comparing pointers to objects and functions.
Jason
=================================================================
From: Nathan Myers <ncm at best.com>
Date: Tue, 15 Jun 1999 13:55:39 -0700 (PDT)
Message-Id: <199906152055.NAA25668 at shell7.ba.best.com>
To: C++ core language mailing list
Message c++std-core-8106
...
No, it leaves the result of comparison between null pointers undefined.
They can be compared, but the result isn't specified for that case.
That may be a problem. Fortunately, we have some existing practice
to fall back on.
Nathan Myers
ncm at cantrip.org
- Jim Dehnert dehnert at sgi.com
(650)933-4272
More information about the cxx-abi-dev
mailing list