public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115230] New: -fvisibility=hidden does not hide Template Specializations from being exported
@ 2024-05-26  7:38 tanksherman27 at gmail dot com
  2024-05-26  7:43 ` [Bug c++/115230] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: tanksherman27 at gmail dot com @ 2024-05-26  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115230
           Summary: -fvisibility=hidden does not hide Template
                    Specializations from being exported
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tanksherman27 at gmail dot com
  Target Milestone: ---

Consider the following code:

#include <cstdlib>

template<typename T>
void method(T* src, T* dst, size_t length);

template<>
void method<short>(short* src, short* dst, size_t length) {

}

template<>
void method<int>(int* src, int* dst, size_t length) {

}

Compiled using command line:
g++ -O3 -fvisibility=hidden -std=c++14 -pedantic -Wpedantic -Wall -Werror
templates.cpp

Linked using:
g++ -shared -o libtemplates.so templates.o

When nm is run over it using nm -gDC libtemplates.so, the following symbols are
seen:
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
0000000000001110 T void method<int>(int*, int*, unsigned long)
0000000000001100 T void method<short>(short*, short*, unsigned long)
                 w __cxa_finalize
                 w __gmon_start__

T void method<int>(int*, int*, unsigned long) and T void method<short>(short*,
short*, unsigned long) should not be in the symbol table, but they are even
with -fvisibility=hidden.

Strangely, marking both methods with [[gnu::visibility("hidden")]] works and
results in both not being exported.

This was recently observed in the JDK, inside the Java HotSpot VM (see
https://github.com/openjdk/jdk/pull/17955/files#r1498933843)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/115230] -fvisibility=hidden does not hide Template Specializations from being exported
  2024-05-26  7:38 [Bug c++/115230] New: -fvisibility=hidden does not hide Template Specializations from being exported tanksherman27 at gmail dot com
@ 2024-05-26  7:43 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-26  7:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 105645 ***

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-26  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-26  7:38 [Bug c++/115230] New: -fvisibility=hidden does not hide Template Specializations from being exported tanksherman27 at gmail dot com
2024-05-26  7:43 ` [Bug c++/115230] " 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).