Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-01-05 15:10:41


> > I should note on gcc the above test give very different results. Since
> > a "struct A{};" must have a size > 0 and combining on struct with another
> > must be on a word boundary (x86), the size of E would be 4+sizeof(void*)
> in
> > the second case and could be as high as 3*4+sizeof(void*) in the first
> > (depending on the order of the inheritance.)
> >
> > This is kind of a good reason to avoid empty base classes like
> > "struct A: public not_newable" as some compilers will cause those
> > classes to become larger than expected, especially when it is for
> > something like a ptr class where a large number may be declared.
>
> Karl,
>
> Which version of GCC are you testing with? GCC 3.0.x uses an aggressive
> algorithm which optimizes away storage for empty bases whenever possible.

Quite right. Gcc 3.0 appears to have fixed this weird behavior.
All previous versions have the behavior I discribed. (Sorry I
hadn't noticed the change.)

--Karl


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk