c++/3631: another linking problem with virtual derivation

snyder@fnal.gov snyder@fnal.gov
Mon Jul 9 20:26:00 GMT 2001


>Number:         3631
>Category:       c++
>Synopsis:       another linking problem with virtual derivation
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 09 20:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        3.0.1 20010703 (prerelease)
>Organization:
>Environment:
System: Linux karma 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../egcs/configure --prefix=/usr/local/egcs --enable-threads=posix --enable-long-long
>Description:

I get an link error compiling the problem, about an undefined virtual
thunk:

$ c++ -o x x.cc
/tmp/ccB0aFEJ.o(.gnu.linkonce.d._ZTC1K12_1J+0xa0): undefined reference to `virtual thunk to G::destroy()'
collect2: ld returned 1 exit status

Here are the symbols containing destroy that we generate in this object:

$ nm -Bo x.o | grep destroy
x.o:00000000 W _ZN1B7destroyEv
x.o:00000000 W _ZN1G7destroyEv
x.o:00000000 W _ZTv0_n20_N1G7destroyEv
x.o:         U _ZTvn8_n20_N1G7destroyEv


This is some sort of name mangling problem?

I think this is the same problem as reported in
http://gcc.gnu.org/ml/gcc-patches/2001-06/msg01636.html

The problem goes away if i revert Jason's last change to class.c
on the 3.0 branch:

2001-06-18  Jason Merrill  <jason_merrill@redhat.com>

	* class.c (dfs_accumulate_vtbl_inits): Just point to the base we're
	sharing a ctor vtable with.  Merge code for cases 1 and 2.
	(binfo_ctor_vtable): New fn.
	(build_vtt_inits, dfs_build_secondary_vptr_vtt_inits): Use it.



>How-To-Repeat:

------------------------------------------------------------
struct A { virtual ~A () {} };

struct B : virtual public A
{
  virtual void destroy() {}
};

class C : virtual public B {};
class D : virtual public C {};
class E : public virtual A {};

struct F : virtual public B, virtual public E
{
  virtual void destroy() = 0;
};

struct G : public virtual F
{
  virtual void destroy() {}
};

class H : virtual public C, virtual public F {};
class I : virtual public D, virtual public H {};
class J : public virtual G, public virtual H {};

class K : public virtual I, public virtual J
{
public:
  virtual ~K();
};
K::~K() {}



int main ()
{
  return 0;
}
------------------------------------------------------------


>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list