https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89009
--- Comment #8 from Stephan Bergmann <sbergman at redhat dot com> --- ...and adding to the test.cc from comment 0 an additional > $ cat main.cc > void f1(); > struct S1 { static void f2(); }; > struct __attribute__ ((visibility("default"))) S2: S1 { static void f2(); }; > struct S3: S1 { static void f2(); }; > struct S4: S3 { static void f2(); }; > void f1() { __builtin_printf("f1\n"); } > void S1::f2() { __builtin_printf("S1::f2\n"); } > int main() { S4::f2(); } > > $ g++ -fvisibility=hidden -fpic -O2 -fno-inline test.cc main.cc > $ ./a.out > f1 to form a complete program still fails for me (GCC 8.2.1).