public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/78160] explicit template instantation with hidden symbols fails
       [not found] <bug-78160-4@http.gcc.gnu.org/bugzilla/>
@ 2024-04-06  5:13 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: pinskia at gcc dot gnu.org @ 2024-04-06  5:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78160

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |visibility
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is the correct behavior for visibility.

Since base_spec_uint8 is hidden, that means the type in the shared library and
the main program are considered 2 different types.

In the case of you explictly instantiate var_t<base_spec_uint8> (which
instantiates var_t<base_spec_uint8>::alloc) but that has a hidden visibility as
base_spec_uint8 has a hidden visbility. so var_t<base_spec_uint8>::alloc will
be hidden in the shared object too and not exported.

From the .s generated from .cc file of the library (passed through the
demangler):
        .hidden var_t<base_spec_uint8>::alloc()

So if you create a share object, well that is going to be hidden inside that
shared object and not exported.

This behavior is described in the manual even:
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Common-Function-Attributes.html
In C++, if a template argument has limited visibility, this restriction is
implicitly propagated to the template instantiation. Otherwise, template
instantiations and specializations default to the visibility of their template.

If both the template and enclosing class have explicit visibility, the
visibility from the template is used.

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

only message in thread, other threads:[~2024-04-06  5:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-78160-4@http.gcc.gnu.org/bugzilla/>
2024-04-06  5:13 ` [Bug c++/78160] explicit template instantation with hidden symbols fails pinskia at gcc dot gnu.org

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).