From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6000A3858CD9; Sun, 26 May 2024 07:38:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6000A3858CD9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716709105; bh=N7hrMeQ+sxIRP0bytgDUeFMzUdXRV8sxMluBakG0zlk=; h=From:To:Subject:Date:From; b=PRbXkEBiR+turS10FIBO50ysPCUJNQ9v3JgBxlfZT6CkU8OqhJStuRxURubkBwQI+ byqKnp84H7SkYcYsWIpBin/Sosdn7o4cJm17raCG0Fbd6a4rUNFxG0UbdLlpqjS8rd f+2nMonHxbv+stoOkXOkSaOczJvjkvKu+yYCJ+rM= From: "tanksherman27 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/115230] New: -fvisibility=hidden does not hide Template Specializations from being exported Date: Sun, 26 May 2024 07:38:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tanksherman27 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115230 Bug ID: 115230 Summary: -fvisibility=3Dhidden 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 template void method(T* src, T* dst, size_t length); template<> void method(short* src, short* dst, size_t length) { } template<> void method(int* src, int* dst, size_t length) { } Compiled using command line: g++ -O3 -fvisibility=3Dhidden -std=3Dc++14 -pedantic -Wpedantic -Wall -Werr= or 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*, unsigned long) 0000000000001100 T void method(short*, short*, unsigned long) w __cxa_finalize w __gmon_start__ T void method(int*, int*, unsigned long) and T void method(shor= t*, short*, unsigned long) should not be in the symbol table, but they are even with -fvisibility=3Dhidden. 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)=