https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116852
Bug ID: 116852 Summary: -fvisibility-inlines-hidden does not hide template functions without 'inline' Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: joerg.rich...@pdv-fs.de Target Milestone: --- # Consider this code: cat > t.cc <<EOF template<class T> void templateFunc() { } template<class T> inline void templateFuncInline() { } struct Bar { void memberFunc() {} inline void memberFuncInline() {} template<class T> void templateMemberFunc() {} template<class T> inline void templateMemberFuncInline() {} }; void func() { templateFunc<int>(); templateFuncInline<int>(); Bar b; b.memberFunc(); b.memberFuncInline(); b.templateMemberFunc<int>(); b.templateMemberFuncInline<int>(); } EOF # Compiled with g++ t.cc -o t.so -shared -fvisibility-inlines-hidden # Symbols readelf --dyn-syms -W t.so ########################## Outputs a weak default visible symbol for templateFunc > 5: 0000000000001165 7 FUNC WEAK DEFAULT 12 > _Z12templateFuncIiEvv but all the other functions will not be default visible. Aren't functions templates implicitly declared inline in C++, like inline defined member functions? Shouldn't the instantiations then also be hidden? A lot of our dynamic symbols are such functions. Adding inline everywhere will fix the issue for us, but this also effects thrid-party code. Is there another way to treat templateFunc as inline in the sense of -fvisibility-inlines-hidden?