c++/4122: undefined reference to `non-virtual thunk to ...'

Robert Boehne rboehne@ricardo-us.com
Thu Dec 20 09:44:00 GMT 2001


Jason Merrill wrote:
> 
> No, it should never be necessary to generate thunks with the vtable; if
> there's a thunk missing, either it should be generated with the function or
> it should not be needed.
> 
> Jason

Jason:

If this statement is true, what is the correct fix for PR4122?
As it is now gcc 3.x is unusable with multiple virtual inheritence,
this patch works to fix that, but if you have a suggestion for
a more elegant fix I would like to hear it.  I must admit that I'm
not sure why this patch was necessry, or why it works, so any
details you could explain (small words please ;) would be greatly
appreciated.  I've altered the test case a bit to clarify the
problem and attached it to this message.  In this case, the
instantiated object has two virtual ancestors.  The class
at the top of the inheritence tree defines two virtual functions
for wich the thunks are unresolved at link time.

Thanks,

Robert

-- 
Robert Boehne             Software Engineer
Ricardo Software   Chicago Technical Center
TEL: (630)789-0003 x. 238
FAX: (630)789-0127
email:  rboehne@ricardo-us.com
-------------- next part --------------
////////////////////////////////////////////////////////////////////
//  PR4122 Demo
//     Multiple (virtual) inheritence is broken.
//  The code below has the class heirarchy shown below.  The keyword
//  "virtual" is used to specify that only one instance of the given
//  class will be instantiated in the tree.  Take out the virtual
//  keyword and the class with then compile.
//
//                   [ServantBase]
//                    /         \
//                   /           \
//   [RefCountServantBase]     [IRObject]
//                  \           /      \
//                   \         /        \
//                 [IRObject_impl]    [Container]
//                           \          /
//                            \        /
//                         [Container_impl]
//
///////////////////////////////////////////////////////////////////

class ServantBase
{
public:
  virtual void _non_existent() {};
  virtual void _ami_existent() {};
  virtual ~ServantBase() {};
};
 
class RefCountServantBase : virtual public ServantBase
{
};
 
class IRObject : virtual public ServantBase
{
};
 
 
 
class IRObject_impl : virtual public RefCountServantBase,
		      virtual public IRObject
{
};
 
class Container : virtual public IRObject
{
};

class Container_impl : public Container,
		       public IRObject_impl
{
};

int
main()
{
  Container_impl x;
  IRObject_impl y;
}


More information about the Gcc-bugs mailing list