g++ and aliasing bools

Daniel Berlin dan@dberlin.org
Sun Jan 27 05:34:00 GMT 2002


On Sat, 26 Jan 2002, Mark Mitchell wrote:

> > The argument can be extended to handle non-virtual single or multiple
> > inheritance: from the C point of view,
> 
> This isn't obvious yet.
> 
> You have to at least discuss zero-sized base classes and whether or not
> GNU C handles them in the same way -- including cases like this:
> 
>   struct A {};
>   struct B : public A {};
>   struct C : public A {};
>   struct D : public B, C {};
> 
> Here, D has size two to avoid having two A's at the same address.
> If C did not derive from A, D would have size one.  In GNU C, does:
> 
>   struct A {};
>   struct B { struct A __base1; };
>   struct C { struct A __base1; };
>   struct D {
>      struct B __base1;
>      struct C __base2;
>   };
> 
> have size two?
> 
No, it has size 0.
> Does the variant where C is empty have size 1?
Nope.

However, this will just cause us to be more conservative than necessary. 
We'll think they have the same address, and thus, alias, rather than say 
they *don't* alias.

Right?



--Dan



More information about the Gcc mailing list