This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 23984
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Oct 2005 09:42:58 +0100
- Subject: [C++ PATCH]: Fix 23984
I've installed this patch to fix 23984. The vtable we want is always the first
one in the vtt parm. No need to add the VPTR_IDX, which might be completely bogus.
built & checked on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2005-10-13 Nathan Sidwell <nathan@codesourcery.com>
PR c++/23984
* class.c (build_base_path): The vtable is always the first thing
in the vtt.
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.735
diff -c -3 -p -r1.735 class.c
*** cp/class.c 12 Oct 2005 20:54:49 -0000 1.735
--- cp/class.c 14 Oct 2005 08:28:27 -0000
*************** build_base_path (enum tree_code code,
*** 325,340 ****
if (fixed_type_p < 0 && in_base_initializer)
{
! /* In a base member initializer, we cannot rely on
! the vtable being set up. We have to use the vtt_parm. */
! tree derived = BINFO_INHERITANCE_CHAIN (v_binfo);
tree t;
! t = TREE_TYPE (TYPE_VFIELD (BINFO_TYPE (derived)));
t = build_pointer_type (t);
v_offset = convert (t, current_vtt_parm);
- v_offset = build2 (PLUS_EXPR, t, v_offset,
- BINFO_VPTR_INDEX (derived));
v_offset = build_indirect_ref (v_offset, NULL);
}
else
--- 325,338 ----
if (fixed_type_p < 0 && in_base_initializer)
{
! /* In a base member initializer, we cannot rely on the
! vtable being set up. We have to indirect via the
! vtt_parm. */
tree t;
! t = TREE_TYPE (TYPE_VFIELD (current_class_type));
t = build_pointer_type (t);
v_offset = convert (t, current_vtt_parm);
v_offset = build_indirect_ref (v_offset, NULL);
}
else
// { dg-do run }
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 13 Oct 2005 <nathan@codesourcery.com>
// PR 23984:ICE
// Origin: Andrew Pinski pinskia@gcc.gnu.org
struct B
{
virtual void Foo ();
};
void B::Foo ()
{
}
struct D : virtual B
{
};
struct E
{
B *ptr;
E (B *);
};
static B *ptr;
E::E (B *ptr_)
:ptr (ptr_)
{
}
struct G : D, E
{
G ();
};
G::G ()
: E (this)
{
}
int main ()
{
G object;
return object.ptr != &object;
}