Duplicate constructors generated

Ian Lance Taylor ian@airs.com
Sun Feb 5 00:18:00 GMT 2006


Matthew Jones <matthewjones@vw1600e.org.uk> writes:

> I am seeing dupicated ctors & dtors in my object files. For large classes this
> leads to considerable bloat. And debugging is a pain as only 1 version is
> linked to the source, and we inevitably see the other one being called.
> 
> I found a previous question about this:
> http://gcc.gnu.org/ml/gcc-help/2004-11/msg00158.html which exactly describes
> what I am seeing, but the answer is not particularly relevant. I get this with
> simple non-virtual classes:

One is the "complete object constructor" and the other is the "base
object constructor."  The difference is that the "complete object
constructor" also constructs the virtual base classes.

I have no idea why g++ generates both for classes with no virtual base
classes.  And if there is some reason for that, then I have no idea
why, when the functions are identical, it doesn't simply use two
symbol names for two instances of the function.

This is gcc PR 3187 (http://gcc.gnu.org/PR3187).  I see that that PR
has been suspended, although I don't agree with the cited reason; we
don't need to do any ABI work to emit two symbols for one copy of the
constructor.

Ian



More information about the Gcc-help mailing list