Vtable incompatibility between GCC 3.0/3.2?

Stephan Bergmann stephan.bergmann@sun.com
Fri Sep 5 10:09:00 GMT 2003


Hi all.

I just found out the hard way :)  that there is an incompatibility in 
the vtable layout of GCC 3.0.1 and GCC 3.2.2, see below.  Can anybody 
confirm whether this is a known issue (a deliberate change?), and 
between which two GCC versions the change was introduced?  I did not 
find anything about this in the changes notes.

Thanks a lot in advance,
-Stephan


Compiling file test.cc

   struct Base1 { virtual void fnBase1(); };
   struct Base2 { virtual void fnBase2(); };
   struct Derived: Base1, Base2 {
     Derived();
     void fnBase2();
     virtual void fnDerived();
   };
   Derived::Derived() {}
   void Derived::fnBase2() {}

with

   g++ -S test.cc

shows that the GCC-3.0.1--generated

   vtable for Derived:
     .long 0
     .long typeinfo for Derived
     .long Base1::fnBase1()
     .long Derived::fnDerived()
     .long Derived::fnBase2()
     .long -4
     .long typeinfo for Derived
     .long non-virtual thunk to Derived::fnBase2()

differs from the GCC-3.2.2--generated

   vtable for Derived:
     .long 0
     .long typeinfo for Derived
     .long Base1::fnBase1()
     .long Derived::fnBase2()
     .long Derived::fnDerived()
     .long -4
     .long typeinfo for Derived
     .long non-virtual thunk [nv:-4] to Derived::fnBase2()

in that the slots for fnDerived and fnBase2 have switched positions.



More information about the Gcc mailing list