public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* ELF symbol visibility vs. member function template instantiations
@ 2016-08-30 11:16 Schneider, Robert
  0 siblings, 0 replies; only message in thread
From: Schneider, Robert @ 2016-08-30 11:16 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-30 11:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30 11:16 ELF symbol visibility vs. member function template instantiations Schneider, Robert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).