https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91086
Bug ID: 91086
Summary: std namespace symbols can get their visibility
degraded
Product: gcc
Version: 9.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jengelh at inai dot de
Target Milestone: ---
Created attachment 46557
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46557&action=edit
g++ -fPIC -fvisibility=hidden -E t.cpp
gcc version 9.1.1 20190611 [gcc-9-branch revision 272147] (SUSE Linux)
» cat t.cpp
#include <memory>
class __attribute__((visibility("hidden"))) H {};
class __attribute__((visibility("default"))) V {};
int main()
{
std::make_shared<H>();
std::make_shared<V>();
}
» g++ -fPIC -shared -fvisibility=hidden -o t.so t.cpp
Observed behavior: The two instances of _Sp_ebo_helper<T>::_S_get have
different visibility.
» nm -C t.so | grep _S_get
000000000000582d t std::_Sp_ebo_helper<0, std::allocator<H>,
true>::_S_get(std::_Sp_ebo_helper<0, std::allocator<H>, true>&)
0000000000005810 W std::_Sp_ebo_helper<0, std::allocator<V>,
true>::_S_get(std::_Sp_ebo_helper<0, std::allocator<V>, true>&)
Expected behavior: That the two instances of _S_get have same visibility
(either both t or both W)
» nm -C t.so | grep _S_get
000000000000582d W std::_Sp_ebo_helper<0, std::allocator<H>,...
0000000000005810 W std::_Sp_ebo_helper<0, std::allocator<V>,...
_S_get (t.i:25368) is inside a template struct _Sp_ebo_helper (t.i:25361) which
is inside a "namespace std __attribute__ ((__visibility__ ("default")))"
(t.i:25008), so I would anticipate that the ebo_helper functions are both
global. (Or, if there is a reason I do not see, both local. But never dependent
upon the visibility of a template argument.)