https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103490

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable
The virtual table for a class is emitted in the same object containing the
definition of its key function, i.e. the first non-pure virtual function that
is not inline at the point of class definition. If there is no key function, it
is emitted everywhere used. The emitted virtual table includes the full virtual
table group for the class, any new construction virtual tables required for
subobjects, and the VTT for the class. They are emitted in a COMDAT group, with
the virtual table mangled name as the identifying symbol. Note that if the key
function is not declared inline in the class definition, but its definition
later is always declared inline, it will be emitted in every object containing
the definition. A constexpr or consteval function is always declared constexpr
or consteval on its first declaration, and is implicitly inline, so is never a
key function.




I think GCC is correct here and LLVM is wrong due to: "They are emitted in a
COMDAT group, with the virtual table mangled name as the identifying symbol."

This was done because of things like:
struct Test1 {
    virtual int getB();
    virtual int getA();
};
inline int Test1 :: getB() {
    return 2;
}

and only the header have Test1 and such.

Reply via email to