This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: about g++ compilation for class constructor/destructor
- From: Brian Dessent <brian at dessent dot net>
- To: drag chan <zgchan317 at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 27 Sep 2008 23:22:22 -0700
- Subject: Re: about g++ compilation for class constructor/destructor
- References: <bbbb7aab0809272259x584eec80x1c3183159d4c0d83@mail.gmail.com>
- Reply-to: gcc at gcc dot gnu dot org
drag chan wrote:
> my question is why every constructor/destructor of class A have a
> couple of same code blocks in the object file?
The ABI requires two separate versions of the ctor and dtor, one for
when the object being initialized is a base class and one where it's
not. Because you used -C to demangle the names you can't see the
difference in the labels, but they really are different symbols.
It just happens that in most cases the two versions have identical
bodies, and they could theoretically be condensend into a single copy
with two labels or two entry points. But doing this has ABI
compatibility implications. It's a non-trivial problem to solve, and a
long-standing wart. See <http://gcc.gnu.org/PR3187>.
Brian