Double constructors in C++?

Ian Lance Taylor iant@google.com
Tue Feb 19 02:45:00 GMT 2008


Samuel Tardieu <sam@rfc1149.net> writes:

> Why are constructors included twice in object code?

This is required by the C++ ABI.

It is, in my opinion, a real bug that gcc does not simply merge
identical constructors.  There are ABI issues with changing, in that
it can change the behaviour of existing code in some very subtle ways
that will probably not break any actual existing code.  We should at
the very least offer this as an ABI_-breaking option for people using
embedded systems or other cases where code size matters.

There is a bug report at http://gcc.gnu.org/PR3187 .

The last patch I know of related to this was
http://gcc.gnu.org/ml/gcc-patches/2007-11/msg01147.html .

> 00000000 <_ZN1TC2ERKSs>:
> 0000000c <_ZN1TC1ERKSs>:

Note that although the demangler demangles them to the same string,
the two functions have different names.

Ian



More information about the Gcc mailing list