public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bo Yang" <techrazy.yang@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Gcc emit wrong symbols in multiple inheritance case
Date: Tue, 29 Jul 2008 10:12:00 -0000	[thread overview]
Message-ID: <a47d5c0807282300q6f101abbx622a118b4252e1d7@mail.gmail.com> (raw)

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

             reply	other threads:[~2008-07-29  6:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29 10:12 Bo Yang [this message]
2008-07-29 14:30 ` Martin Krischik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a47d5c0807282300q6f101abbx622a118b4252e1d7@mail.gmail.com \
    --to=techrazy.yang@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).