This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[C++ PATCH]: Fix 3631 (2.95 regression)


Mark,
This fixes bug 3631, which is another ABI vbase bug.

We miscalculated the fixed offset part of a virtual thunk residing
in a lost-primary. We need the offset from the original declaring
base to its closest enclosing virtual base.

booted & tested on i686-pc-linux-gnu, ok for branch & mainline?

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-07-29  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/3631
	* class.c (update_vtable_entry_for_fn): Fixed adjustment of a
	virtual thunk should be from declaring base.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.401
diff -c -3 -p -r1.401 class.c
*** class.c	2001/07/27 15:12:48	1.401
--- class.c	2001/07/29 20:10:50
*************** update_vtable_entry_for_fn (t, binfo, fn
*** 2563,2572 ****
       (or one of its primary bases, which are at the same offset).  */
  
    if (virtual_base)
!     /* The `this' pointer needs to be adjusted to the nearest virtual
!        base.  */
      delta = size_diffop (BINFO_OFFSET (virtual_base),
! 			 BINFO_OFFSET (binfo));
    else
      {
        /* The `this' pointer needs to be adjusted from pointing to
--- 2563,2572 ----
       (or one of its primary bases, which are at the same offset).  */
  
    if (virtual_base)
!     /* The `this' pointer needs to be adjusted from the declaration to
!        the nearest virtual base.  */
      delta = size_diffop (BINFO_OFFSET (virtual_base),
! 			 BINFO_OFFSET (first_defn));
    else
      {
        /* The `this' pointer needs to be adjusted from pointing to
*************** update_vtable_entry_for_fn (t, binfo, fn
*** 2580,2586 ****
  	  /* We'll need a thunk.  But if we have a (perhaps formerly)
  	     primary virtual base, we have a vcall slot for this function,
  	     so we can use it rather than create a non-virtual thunk.  */
! 
  	  b = get_primary_binfo (first_defn);
  	  for (; b; b = get_primary_binfo (b))
  	    {
--- 2580,2586 ----
  	  /* We'll need a thunk.  But if we have a (perhaps formerly)
  	     primary virtual base, we have a vcall slot for this function,
  	     so we can use it rather than create a non-virtual thunk.  */
! 	  
  	  b = get_primary_binfo (first_defn);
  	  for (; b; b = get_primary_binfo (b))
  	    {
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 29 Jul 2001 <nathan@codesourcery.com>

// Origin snyder@fnal.gov
// Bug 3631. We mis-calculated the non-virtual part of a virtual
// thunk. Leading to a link failure, in this case.

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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]