about g++ compilation for class constructor/destructor
Mon Sep 29 18:34:00 GMT 2008
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>.
More information about the Gcc