Method template visibility ignored on explicit template instantiations (original) (raw)
Extended Description
% cat vis.cpp
template <class T> struct s {
template <class U>
__attribute__((__visibility__("hidden"))) U should_not_be_exported();
};
template <class T> template <class U> U s<T>::should_not_be_exported() {
return U();
}
extern template struct __attribute__((__visibility__("default"))) s<int>;
int f() {
s<int> o;
return o.should_not_be_exported<int>();
}
% g++ -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden -shared -fPIC -o libvis.so vis.cpp &&
nm -g --defined-only libvis.so | grep should_not_be_exported
% clang++ -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden -shared -fPIC -o libvis.so vis.cpp &&
nm -g --defined-only libvis.so | grep should_not_be_exported
00000000000006b0 W _ZN1sIiE22should_not_be_exportedIiEET_v