https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81973
Bug ID: 81973 Summary: Aliased virtual methods are treated as undefined, so the vtable is not generated Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blaffablaffa at gmail dot com Target Milestone: --- test case: #include <iostream> using namespace std; struct b{ int a; virtual void f(){ cout<<__PRETTY_FUNCTION__<<' '<<a<<endl; } }; struct s : b{ #ifdef VIRT_ALIAS virtual void f() __attribute__ ((alias ("s_f_alias"))); #endif void g() __attribute__ ((alias ("s_g_alias"))); }; extern "C"{ void s_f_alias(s* this_){ cout<<__PRETTY_FUNCTION__<<' '<<this_->a<<endl; } void s_g_alias(s* this_){ cout<<__PRETTY_FUNCTION__<<' '<<this_->a<<endl; } } int main(){ s a; a.a = 123; a.f(); a.g(); } Compiling without -DVIRT_ALIAS works, output is: virtual void b::f() 123 void s_g_alias(s*) 123 Compiling with -DVIRT_ALIAS gives an error at link time because s::f is treated as not defined, even though it would be possible to use s_f_alias as the definition and put its pointer in the vtable. Expected output is: void s_f_alias(s*) 123 void s_g_alias(s*) 123