https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103490
Bug ID: 103490 Summary: Linkage type of typeinfo of polymorphic object with OOL functions Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lizekun.zek at bytedance dot com Target Milestone: --- Hi guys, I found that the linkage of typeinfo of polymorphic object with OOL-functions is weak, while that is strong for clang, and I want to attach a patch to make the behavior of the two compilers consistent. However, I can't find the clear definition of this in Itanium C++ ABI, so here are the questions: 1.It is easy to understand that we make the object with inlined-functions weak, because it usually appears in a header file and may be defined several times, so when functions are out-of-line, why do we make it weak? 2.In fact, I prefer the gcc way, are there any cases that show gcc is better? This is a case to show the issue. --- test.h class A{ public: virtual const int getA(){} ; virtual const int getB(){} ; }; --- testA.cpp #include<iostream> #include "test.h" using namespace std; class Test : public A { public: virtual const int getA() override; }; const int Test ::getA() { return 1; } int main() { A * t=new Test();; cout << dynamic_cast<Test*>(t); } --- testB.cpp #include "test.h" class Test : A { public: virtual const int getB() override; }; const int Test :: getB() { return 2; }