Bug 21264 - duplicate symbol warnings for complex template class
Summary: duplicate symbol warnings for complex template class
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: link-failure
Depends on:
Blocks:
 
Reported: 2005-04-28 12:07 UTC by Jörg Richter
Modified: 2006-05-31 14:57 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc-ibm-aix5.2.0.0
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Richter 2005-04-28 12:07:51 UTC
/// template.cc /////////////////////////////////////////
struct VirtualBase
{
    virtual ~VirtualBase();
};

struct Foo
{};

struct Bar
{
    virtual ~Bar();
};

template<class OtherBase>
class Test : public VirtualBase, public OtherBase
{
};

void func()
{
  Test<Foo> foo;
  Test<Bar> bar;
}

//////////////////////////////////////////

$ /tools/pkg/gcc/3.4.3/bin/g++ -shared -Wl,-G -o lib343.so template.cc
$ dump -Tv lib343.so | c++filt

IMEX Sclass   Type           IMPid Name
 EXP     DS   Ldef        [noIMid] Test<Bar>::~Test()
 EXP     DS   Ldef        [noIMid] Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] non-virtual thunk to Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] non-virtual thunk to Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] Test<Foo>::~Test()
wEXP     DS SECdef        [noIMid] Test<Foo>::~Test()


$ /tools/pkg/gcc/3.3.3/bin/g++ -shared -Wl,-G -o lib333.so template.cc
$ dump -Tv lib333.so | c++filt

IMEX Sclass   Type           IMPid Name
wEXP     DS SECdef        [noIMid] Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] non-virtual thunk to Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] non-virtual thunk to Test<Bar>::~Test()
wEXP     DS SECdef        [noIMid] Test<Foo>::~Test()
wEXP     DS SECdef        [noIMid] Test<Foo>::~Test()

Note that I edited the dump output to reduce its size.

Here you can see, that the Test<...>::~Test() destructor gets a different IMEX. 
Depending on its template parameter and/or compiler version.

I dont know exactly what the difference between EXP and wEXP is, but I suspect 
that this has something to do with weak symbols. But on the other hand, I 
always read that AIX supports no weak symbols.

Nevertheless, when using the class Test<Bar> in different shared libraries 
which get linked together, you get warnings about duplicate symbols. This 
warnings were not present with GCC 3.3.3.

I am very nervous when seeing duplicate symbols. Especially on AIX. I had great 
times in the past analysing problems with uncaught exceptions that were caused 
by duplicate symbols.
Comment 1 David Edelsohn 2005-05-03 19:09:51 UTC
AIX 5.2 supports weak symbols, when using AIX assembler and linker.  wEXP 
means weak export and EXP means export.

I do not see this problem when using GCC 4.0.  I am not sure if the patch for 
this was or will be backported to GCC 3.4.
Comment 2 Andrew Haley 2005-05-17 14:49:08 UTC
*** Bug 20088 has been marked as a duplicate of this bug. ***
Comment 3 Wolfgang Bangerth 2006-05-31 02:28:17 UTC
Can you verify whether this problem persists in the gcc 4.0.x series or
later? gcc 3.4.x is no longer maintained, and any patch will not be
backported.

Thanks
  W.
Comment 4 Jörg Richter 2006-05-31 07:21:07 UTC
I can't see the problem with 4.1.1.
Comment 5 Wolfgang Bangerth 2006-05-31 14:57:22 UTC
Thanks for the feedback. It is apparently fixed then...

W.