------- Comment #5 from janus at gcc dot gnu dot org 2010-07-30 18:39 ------- (In reply to comment #4) > admittedly, I do not fully understand the code which sets > the TBP to the vtable - shouldn't this be done when the vtable for a type is > created rather than every time before it is used?
Well, this is a bit tricky. We do not want to generate unnecessary code for non-OOP programs, therefore we can not simply create a vtab for each derived type, but we only do that if a type is actually used as a CLASS. Another problem is that the vtab init code can be generated multiple times if there are multiple CLASS usage cases in a program (blowing up code size). It might be of advantage to put the vtab init code in a special subroutine. [Preferrably in the same module where the type is declared, but this only makes sense if the module contains polymorphic code.] -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44912