public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Gcc emit wrong symbols in multiple inheritance case
@ 2008-07-29 10:12 Bo Yang
  2008-07-29 14:30 ` Martin Krischik
  0 siblings, 1 reply; 2+ messages in thread
From: Bo Yang @ 2008-07-29 10:12 UTC (permalink / raw)
  To: gcc-help

Hi Dear Gcc developers,

   When I am trying to build Mozilla with gcc-mingw, I came across
the linkage error of undefined symbols in multiple inheritance case.
And I have made a simple test case to reproduce the problem. But the
test case is still very complex, I think. So, I came down to find the
what are the real problems. And now, I think I have, so I just
describe what I found here:

For a class hierarchy :

class SuperSuperBase {
public:
       SuperSuperBase();
       ~SuperSuperBase();

       virtual void __attribute__((__stdcall__)) funcSSB() = 0;
};

class SuperBase : public SuperSuperBase {
public:
       SuperBase();
       ~SuperBase();

       virtual void __attribute__((__stdcall__)) funcSB() = 0;
};

class Base : public SuperBase {
public:
       Base();
       ~Base();

       virtual void __attribute__((__stdcall__)) funcB() = 0;
};

class ChildA: public Base {
public:
       ChildA();
       ~ChildA();

       virtual void __attribute__((__stdcall__)) funcCA() = 0;
};

class ChildB: public SuperBase {
public:
       ChildB();
       ~ChildB();

       virtual void __attribute__((__stdcall__)) funcCB() = 0;
};

class DLL Child :       public  ChildA,
                public  ChildB {
public:
       Child();
       ~Child();

       virtual void __attribute__((__stdcall__)) funcSSB();
       virtual void __attribute__((__stdcall__)) funcSB();
       virtual void __attribute__((__stdcall__)) funcB();
       virtual void __attribute__((__stdcall__)) funcCB();
       virtual void __attribute__((__stdcall__)) funcCA();
};

I make the Child in a DLL and then I import it from the DLL to build a
test application. But I failed with the undefined symbols of
"funcSSB,funcSB,funcCB".
And the errors occurs when I build with gcc 4.3.0 but not with gcc
3.4.2. So, I use i686-mingw32-nm to dump the object file which
contains the definition of the Child class. And for the three
undefined functions, the two compiler output different symbols,
Gcc 3.4.2:
        U __ZTVN10__cxxabiv117__class_type_infoE
        U __ZTVN10__cxxabiv120__si_class_type_infoE
        U __ZTVN10__cxxabiv121__vmi_class_type_infoE
00000000 T __ZThn4_N5Child6funcCBEv@4
00000000 T __ZThn4_N5Child6funcSBEv@4
00000000 T __ZThn4_N5Child7funcSSBEv@4

Gcc 4.3.0:
        U __ZTVN10__cxxabiv117__class_type_infoE
        U __ZTVN10__cxxabiv120__si_class_type_infoE
        U __ZTVN10__cxxabiv121__vmi_class_type_infoE
00000306 T __ZThn4_N5Child6funcCBEv
        U __ZThn4_N5Child6funcCBEv@4
000002d7 T __ZThn4_N5Child6funcSBEv
        U __ZThn4_N5Child6funcSBEv@4
000002c8 T __ZThn4_N5Child7funcSSBEv
        U __ZThn4_N5Child7funcSSBEv@4

I think the difference here is the key point of the linkage error.
Could anybody help to give some more insight here? Any advice will be
appreciated very much!

Regards!
Bo

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

* Re: Gcc emit wrong symbols in multiple inheritance case
  2008-07-29 10:12 Gcc emit wrong symbols in multiple inheritance case Bo Yang
@ 2008-07-29 14:30 ` Martin Krischik
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Krischik @ 2008-07-29 14:30 UTC (permalink / raw)
  To: gcc-help


Zitat von Bo Yang <techrazy.yang@gmail.com>:

> class DLL Child :       public  ChildA,
>                 public  ChildB {

Independent of any GCC bug, non-virtual diamond inheritance is  
considered is evil. Most likely you really want:

class DLL Child :
    public virtual ChildA,
    public virtual ChildB {

Regards

Martin

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

end of thread, other threads:[~2008-07-29 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-29 10:12 Gcc emit wrong symbols in multiple inheritance case Bo Yang
2008-07-29 14:30 ` Martin Krischik

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