This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Double abstract class Inheritance concern.


Chris Lattner wrote:
> > I believe the reason is that the ABI does not permit multiple different
> > instances of A to be located at the same address, even if they have zero
> > size.  If the size of the structure was 8, all of "A", "B", and "A" would
> > have offset zero.
> > 
> > I'm not sure WHY this is required, but this is the reason it happens at
> > least.  A declaration of "A X[100];" allocates 100 bytes as
> > a result of the same rule.

On Mon, Mar 29, 2004 at 08:57:17AM +0100, Nathan Sidwell wrote:
> It is a C++ language requirement that no two logically distinct objects
> of the same type have the same address.

However, g++ still finds plenty of opportunities to allocate zero bytes
for a struct/class object, when it is not adjacent to any other objects of the
same type (e.g. an empty base class, or an empty data member of a struct
or class).



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]