http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58585
--- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> --- This is the code I am playing with: /* Walk bases. */ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) /* Walking bases that have no virtual method is pointless excercise. */ if (polymorphic_type_binfo_p (base_binfo)) record_binfo (nodes, base_binfo, otr_type, /* In the case of single inheritance, the virtual table is shared with the outer type. */ BINFO_OFFSET_ZEROP (base_binfo) ? type_binfo : base_binfo, otr_token, inserted, matched_vtables, anonymous); (i.e. using BINFO_OFFSET_ZEROP check instead of BINFO_VTABLE != NULL). I think I understand the problem now. The binfos of C looks like BINFO of C, BINFO vtable is C's vtable BASE: BINFO of B, BINFO vtable is non-NULL, offset is 8 BASE: BINFO of A, BINFO vtable is non-NULL, offset is 0. i.e. by the virtual inheritance the A is outside layout of B. So while B's VTABLE is set, A's VTABLE should be VTABLE of C, my code however considers VTABLE of B. get_binfo_at_offset won't get confused, since type of C contains both A and B as fields, so it gets to BINFO of A directly without walking BINFO of B. Is there way how to keep track of the vtables w/o doing the walk based on fields instead of BINFO_BASEs? If not, I will simply switch record_binfos to it - it seems quite straighforward, but it will end up with more walking, since there are more fileds than bases.