public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Question about duplicate C++ functions generated with GNU 3.4.1
@ 2004-11-24  3:05 Ramadass, Ramanathan
  2004-11-24 14:55 ` Nathan Sidwell
  0 siblings, 1 reply; 5+ messages in thread
From: Ramadass, Ramanathan @ 2004-11-24  3:05 UTC (permalink / raw)
  To: Nathan Sidwell, Jon Watson; +Cc: gcc-help

>It is to do with ctors-for-most-derived and ctors-for-base.

Could you please elaborate on this? I too have been trying to understand
why two copies of ctors are getting created but could never find any
explanation. As you suggested, i browsed through the ABI but still
haven't found anything(so far). From your remark;

>There is a bug report pointing out that, where virtual bases are not
involved,
>these two things are the same

Can i infer that it has to do with the initialization of the pointer to
the virtual base class in a derived object? Somewhere in lippman's
"Inside the C++ object model" i had read that the ctor inits this
pointer. Not sure that it is related. Would appreciate it if you(or
somebody else) could throw some light on this.

Thanks
Ram

-----Original Message-----
From: Nathan Sidwell [mailto:nathan@codesourcery.com]
Sent: Tuesday, November 23, 2004 7:40 AM
To: Jon Watson
Cc: gcc-help@gcc.gnu.org
Subject: Re: Question about duplicate C++ functions generated with GNU
3.4.1


Jon Watson wrote:
> Hi -
> 
> We recently switched to GCC 3.4.1 (built for PowerPC EABI). As we have
started to recompile our code and bring up our products we noticed some
odd behavior. Specifically, it appears that GCC has created two
functionally identical copies of C++ object constructors that are
referenced by different symbols...

> Symbols for BufferPool::BufferPool():
> 00002c78 T _ZN10BufferPoolC2Ev
./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\Buffer
Pool.cpp:91
> 00002c88 T _ZN10BufferPoolC1Ev
./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\Buffer
Pool.cpp:91

It is to do with ctors-for-most-derived and ctors-for-base.  Refer
to the ABI document (linked to from Further Readings) for details.  I
thought
there qas a faq or something about it, but I cannot find it right now.
There is a bug report pointing out that, where virtual bases are not
involved,
these two things are the same.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery
LLC
nathan@codesourcery.com    ::
http://www.planetfall.pwp.blueyonder.co.uk

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

* Re: Question about duplicate C++ functions generated with GNU 3.4.1
  2004-11-24  3:05 Question about duplicate C++ functions generated with GNU 3.4.1 Ramadass, Ramanathan
@ 2004-11-24 14:55 ` Nathan Sidwell
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Sidwell @ 2004-11-24 14:55 UTC (permalink / raw)
  To: Ramadass, Ramanathan; +Cc: Jon Watson, gcc-help

Ramadass, Ramanathan wrote:
>>It is to do with ctors-for-most-derived and ctors-for-base.
> 
> 
> Could you please elaborate on this? I too have been trying to understand
> why two copies of ctors are getting created but could never find any
> explanation. As you suggested, i browsed through the ABI but still
> haven't found anything(so far). From your remark;

http://www.codesourcery.com/cxx-abi/abi.html#vtable-ctor
and http://www.codesourcery.com/cxx-abi/abi.html#obj-ctor
talks about it, but probably not in the most enlightening terms.

> Can i infer that it has to do with the initialization of the pointer to
> the virtual base class in a derived object? Somewhere in lippman's
> "Inside the C++ object model" i had read that the ctor inits this
> pointer. Not sure that it is related. Would appreciate it if you(or
> somebody else) could throw some light on this.

that presumes a particular ABI implementation, which is now incorrect for
g++   However the basic idea is the same.

nathan
-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

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

* Re: Question about duplicate C++ functions generated with GNU 3.4.1
  2004-11-22 21:11 Jon Watson
@ 2004-11-23 15:40 ` Nathan Sidwell
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Sidwell @ 2004-11-23 15:40 UTC (permalink / raw)
  To: Jon Watson; +Cc: gcc-help

Jon Watson wrote:
> Hi -
> 
> We recently switched to GCC 3.4.1 (built for PowerPC EABI). As we have started to recompile our code and bring up our products we noticed some odd behavior. Specifically, it appears that GCC has created two functionally identical copies of C++ object constructors that are referenced by different symbols...

> Symbols for BufferPool::BufferPool():
> 00002c78 T _ZN10BufferPoolC2Ev	./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:91
> 00002c88 T _ZN10BufferPoolC1Ev     ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:91

It is to do with ctors-for-most-derived and ctors-for-base.  Refer
to the ABI document (linked to from Further Readings) for details.  I thought
there qas a faq or something about it, but I cannot find it right now.
There is a bug report pointing out that, where virtual bases are not involved,
these two things are the same.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

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

* Re: Question about duplicate C++ functions generated with GNU  3.4.1
@ 2004-11-23 13:07 Eljay Love-Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Eljay Love-Jensen @ 2004-11-23 13:07 UTC (permalink / raw)
  To: Jon Watson, gcc-help

Hi Jon,

Are there, perhaps, two constructors in the BufferPool class?

$ c++filt _ZN10BufferPoolC2EPNS_13MemDescriptorES1_PNS_16NumBufDescriptorEjtPc
BufferPool::BufferPool(BufferPool::MemDescriptor*, 
BufferPool::MemDescriptor*, BufferPool::NumBufDescriptor*, unsigned int, 
unsigned short, char*)

$ c++filt _ZN10BufferPoolC2Ev
BufferPool::BufferPool()

HTH,
--Eljay

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

* Question about duplicate C++ functions generated with GNU 3.4.1
@ 2004-11-22 21:11 Jon Watson
  2004-11-23 15:40 ` Nathan Sidwell
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Watson @ 2004-11-22 21:11 UTC (permalink / raw)
  To: gcc-help

Hi -

We recently switched to GCC 3.4.1 (built for PowerPC EABI). As we have started to recompile our code and bring up our products we noticed some odd behavior. Specifically, it appears that GCC has created two functionally identical copies of C++ object constructors that are referenced by different symbols...

For example, we have a class, BufferPool, which defines a default constructor BufferPool::BufferPool() and an overloaded constructor BufferPool::BufferPool( ... ), which accepts several arguments. When we look at the symbols and at the assembly listing we see there are two (unique) symbols (at different addresses) for each constructor that refer to the same C++ code... 

The symbols look like this (as dumped from the object file with nm):

Symbols for BufferPool::BufferPool():
00002c78 T _ZN10BufferPoolC2Ev	./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:91
00002c88 T _ZN10BufferPoolC1Ev     ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:91

Symbols for BufferPool::BufferPool(...):
00002c98 T _ZN10BufferPoolC2EPNS_13MemDescriptorES1_PNS_16NumBufDescriptorEjtPc ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:119
0000336c T _ZN10BufferPoolC1EPNS_13MemDescriptorES1_PNS_16NumBufDescriptorEjtPc ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:119

When we disassembled the object file and reviewed the contents of both versions of the function we verified they are identical and do the same thing (both would function correctly)... This behavior doesn't appear to be creating an execution problem, but it has caused some confusion when setting breakpoints and stepping through code. Also, it seems to add bloat to the objects for no purpose.

My questions are:

1) Why is GCC generating two identical copies of the same constructor/function generated with different symbol names?

2) Is there a way to prevent this? (I looked at the GCC manuals and nothing jumped out at me...) 

Thanks in advance for any help you can offer...

Jon Watson
Airvana, Inc

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

end of thread, other threads:[~2004-11-24 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-24  3:05 Question about duplicate C++ functions generated with GNU 3.4.1 Ramadass, Ramanathan
2004-11-24 14:55 ` Nathan Sidwell
  -- strict thread matches above, loose matches on Subject: below --
2004-11-23 13:07 Eljay Love-Jensen
2004-11-22 21:11 Jon Watson
2004-11-23 15:40 ` Nathan Sidwell

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).