🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Must derived class reserve space for an empty base class?

#1225
From: Johan Bengtsson
Date: Sat, 12 Dec 1992 17:23
46 lines
2481 bytes
Jim Adcock (jimad@microsoft.com) wrote:
: jbn@lulea.trab.se (Johan Bengtsson) writes:
: |Jim Adcock (jimad@microsoft.com) wrote:
: |: steve@taumet.com (Steve Clamage) writes:
: |: |jimad@microsoft.com (Jim Adcock) writes:
: |: ||In "C" common implementation would make &g and &g.e identical,
: |: ||contradicting your assumptions.
: |: |
: |: |I don't this can happen in C, since you can't define a zero-sized object
: |: |or type.
[...]
: |: |On that basis, C compatibility would not seem to be an issue.
: |
: |: But the struct need not be empty for &g and &g.e to be identical.
: |
: |But it must, at least to produce two pointers of the same type that
: |compare equal.  Also, "g" and "g.e" must share a common superclass
: |for this to happen (within the type system).

: Below find legal C and C++ programs with non-empty structs where "g" and
: "g.e" compare equal.

Jim, we have obviously not been clear enough (me and Steve).  Yes,
the address of an object and its first member _cast to void*_ may
compare equal, so code handling void pointers must not assume
this kind of pointer distinctness.  However, neither "&g" nor "&g.e"
is of type void*.

[ Questionable C example involving compiler-generated conversion
  to void* deleted ]

The fact that applying the adress operator (&) to a reference yields
a pointer to the referred-to object is irrelevant, since a reference
is just an alias for the referred-to object.  You cannot obtain
a pointer to a reference (as you already know).  This should not cause
any trouble.

[ C++ example involving a reference data member that refers to *this deleted ]

Perhaps with this clarification you can finally agree with us?

-- 
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
--------------------------------------------------------------------------
Technical Details
Message-ID: <5367@miramon.lulea.trab.se>
Path: arc1-ca.pugleaf.net!sparky!uunet!enterpoop.mit.edu!eru.mt.luth.se!hagbard!loglule!jbn
References: <1992Dec10.194445.24332@microsoft.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!enterpoop.mit.edu!eru.mt.luth.se!hagbard!loglule!jbn
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.std.c++
Subject: Re: Must derived class reserve space for an empty base class?
Message-ID: <5367@miramon.lulea.trab.se>
Date: 12 Dec 92 17:23:39 GMT
References: <1992Dec10.194445.24332@microsoft.com>
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
Lines: 46
X-Newsreader: TIN [version 1.1 + PL8]