https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88335
--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jason Merrill from comment #15) > Would it work to include them at the end of BINFO_VIRTUALS but omit them > in build_vtbl_initializer? With my very limited understanding, I thought that for the vtables it is important that if a base defines some virtual method that for a derived type which either doesn't override it or overrides it the same virtual method has the same index. Now, if the consteval virtuals are at the end of BINFO_VIRTUALS but indexed from the start as others, if say base has 3 normal and 2 consteval virtual methods, 0/1/2 indexes will be the normal and 3/4 will be the consteval ones. If I derive a class from this, don't override the first normal virtual method, override the second one (dtor, two entries), don't override the first consteval method, override the second one and add one new normal and one new consteval methods, like: struct base { virtual int foo (); virtual ~base (); virtual consteval int bar () { return 42; } virtual consteval int baz () { return 43; } }; struct derived : public base { virtual ~derived (); virtual consteval int baz () { return 44; } virtual int qux (); virtual consteval int quux () { return 45; } }; what would happen with indexes in derived BINFO_VIRTUALS? If the non-consteval ones need to go first as that is what we emit into vtables, then qux needs to have index 3, but doesn't bar already have that? The only thing that comes to my mind is to use e.g. negative indexes for the consteval methods and count in that case from the end, i.e. foo would get DECL_VINDEX 0, dtors DECL_VINDEX 1/2, bar DECL_VINDEX -1, baz DECL_VINDEX -2, qux DECL_VINDEX 3 and quux DECL_VINDEX -3 and when actually looking up the entry in BINFO_VIRTUALS, transform negative indexes into chain_length (BINFO_VIRTUALS) + DECL_VINDEX, i.e. bar would be the last in BINFO_VIRTUALS chain of both base and derived, baz the penultimate and quux in derived the antepenultimate. Thoughts on that?