public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Duplicate constructors generated
@ 2006-02-02 10:22 Matthew Jones
  2006-02-05  0:18 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Jones @ 2006-02-02 10:22 UTC (permalink / raw)
  To: gcc-help

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:

This trivial code:

  class A
  {
  public:
      int a;
      A ();
  };

  A::A (void) : a(0) {}

  int main (void)
  {
      A a;
      return 0;
  }

Produces this object file:

  0000002c T A::A()
  00000000 T A::A()
           U __eabi
  00000058 T main

Mangled:

  0000002c T _ZN1AC1Ev
  00000000 T _ZN1AC2Ev
           U __eabi
  00000058 T main

Generated assembler for the 2 constructors is identical.

I couldn't find any gcc bugzilla reports on this, or reference to it in release
notes. In which version is it fixed?

Is there any way to stop it?

I found elusive references to -fcoalesce, but this is only for Apple versions of
gcc.

The original response refers to an ABI document. There are many of these in the
further reading section. Which one is relevant?!

gcc -v
Using built-in specs.
Configured with: /cygdrive/c/gnu/src/gcc-3.4.3/configure --target=powerpc-ibm-ea
bi --host= --prefix=/cygdrive/c/gcc-install --with-cpu=440 --enable-cxx-flags=-m
cpu=440 --with-headers=/cygdrive/c/gcc-install/powerpc-ibm-eabi/include --disabl
e-nls --enable-symvers=gnu --enable-languages=c,c++ --disable-shared --with-newl
ib
Thread model: single
gcc version 3.4.3

Can anyone shed more light on this ?! Thanks...

-- 
Matthew JONES
http://www.tandbergtv.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Duplicate constructors generated
  2006-02-02 10:22 Duplicate constructors generated Matthew Jones
@ 2006-02-05  0:18 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2006-02-05  0:18 UTC (permalink / raw)
  To: Matthew Jones; +Cc: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-05  0:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-02 10:22 Duplicate constructors generated Matthew Jones
2006-02-05  0:18 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).