This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: size of derived classes - misfeature of gcc?
- To: gcc-help at gcc dot gnu dot org, gcc at gcc dot gnu dot org, szegedy at or dot uni-bonn dot de
- Subject: Re: size of derived classes - misfeature of gcc?
- From: Mike Stump <mrs at windriver dot com>
- Date: Mon, 7 May 2001 10:11:49 -0700 (PDT)
> Date: Mon, 7 May 2001 15:45:11 +0200
> From: Christian Szegedy <szegedy@or.uni-bonn.de>
> To: gcc-help@gcc.gnu.org, gcc@gcc.gnu.org
> I've got a question regarding the size and type management of gcc.
> Suppose that I ompile the follwoing programm using gcc 2.95.2 or
> 2.95.3:
> Then, I would except that C and B have both size 4, and therefore the output
> should be:
> 1 4 4
> The result of this run is:
> 1 8 4
> for some reason I don't understand.
> Is there some important reason for gcc to behave in this way?
Backwards compatibility is the main reason.
> Are the future versions of gcc going to have this misfeature?
No. The upcoming gcc 3.0 I think will print 1 4 4 as I recall.
Please don't post to gcc-help and gcc at the same time, thanks.
Hope this helps. If you'd like more background information, search on
google/dejanews for empty base class optimization, I'm sure lots of
folks have said lots about it already.