[C++ bug] Recent vtable regression
Nathan Sidwell
nathan@acm.org
Wed Feb 9 01:42:00 GMT 2000
Mark,
your recent reorganisation of the vtable code has broken multiple
inheritance :-(
2000-01-31 Mark Mitchell <mark@codesourcery.com>
I attach several files,
nathan93.ii - a source file which lays out some vtables
nathan93.s - the compilation of nathan93.ii
nathan94.C - a test case
This occurs both on i86-linux and sparc-solaris (though the vtable
structure is different for those architectures, the same effect
occurs). These examples are from i86-linux
nathan93.s was generated with -O2, that just cuts down its size, the
vtable is the same as -O0. The vtables to look at are,
__vt_5Multi:
.long 0
.long __tf5Multi
.long _._5Multi
.long Wibble__4Core
.long Wobble__4Core
.long Bogus__5Multi
.long Bink__4Base
.long Bonk__4Base
.long Stomped__5Multi
.long Bunk__5Multi
which has a Stomped__5Multi as the penultimate entry. A derivation
of this class is Trail, who's vtable is,
__vt_5Trail:
.long 0
.long __tf5Trail
.long _._5Trail
.long Wibble__4Core
.long Wobble__4Core
.long Bogus__5Multi
.long Bink__4Base
.long Bonk__4Base
.long Bogus__5Multi
.long Bunk__5Multi
which, you'll notice has two instances of Bogus__5Multi. The latter one
having clobbered Stomped__5Multi. It's something about the multiple
inheritance of Multi, and changing the number of virtual functions in
Side moves where the second Bogus__5Multi appears in Trail's vtable.
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
struct Core
{
virtual ~Core ();
virtual void Wibble ();
virtual void Wobble ();
virtual void Bogus ();
};
struct Side
{
virtual ~Side ();
virtual void Arfle ();
virtual void Barfle ();
virtual void Gloop ();
virtual void Glorp ();
virtual void Glump ();
virtual void Bogus ();
};
struct Base : Core
{
virtual ~Base ();
virtual void Bink ();
virtual void Bonk ();
virtual void Bogus ();
};
struct Multi : Base, Side
{
virtual ~Multi ();
virtual void Stomped ();
virtual void Bunk ();
virtual void Bogus ();
};
struct Trail : Multi
{
virtual ~Trail ();
};
Multi::~Multi () {}
Trail::~Trail () {}
More information about the Gcc-bugs
mailing list