ELF symbol visibility vs. member function template instantiations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Consider a free function template

template<typename T>
void __attribute__((visibility("default"))) free_func();

that is instantiated with a type that is hidden:

struct __attribute__((visibility("hidden"))) HiddenType {};

then the resulting function template instantiation free_func<HiddenType> is hidden as well.
However, when I do the same with a member function template of a visible class:

struct __attribute__((visibility("default"))) OuterClass
{
    template<typename T>
    void __attribute__((visibility("default"))) member_func();
};

then the resulting member function template instantiation OuterClass::member_func<HiddenType> is visible.
If OuterClass however is hidden, then OuterClass::member_func<HiddenType> is hidden as well.

==> Why does the visibility of member function template instantiations depend on the visibility of the class? <==
Namespace visibility doesn't affect free function templates in the same way.

clang by the way hides OuterClass::member_func<HiddenType> independently of the visibility of OuterClass.

I've stumbled upon this behaviour when working with facets (of std::locale), which are used by libstdc++ both from free function templates and member function templates.
When the facet type is hidden but used in multiple shared objects, problems arise because only some of the libstdc++ function template instantiations are visible and those get interposed.
This causes problems with identification of the facets via std::locale::id.
(I know how to solve those issues, I'm more interested in what causes them.)


Thanks and kind regards,
Robert




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux