From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5D350385842B; Fri, 23 Feb 2024 13:41:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D350385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708695660; bh=mo1gZP1GTirq5FXC2Y9esrYgwCBi9gcdnpIROUxXT3U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xznNOXZfb8x/74RvQ5sxpARHd5wmUdrz1VUiL1U7W4fPGT5pmjQ+6UQHiqObrsylr PjcmyviKl/AZaFudux1iXR/IbperWNYKPOxAYtNvxYZcFa8uwwFc1trKOQB1pQ2H5M V0ICHErj2Q8wt9vwN5SROl/GI453AwHPW1fMX5X8= From: "tanksherman27 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105645] Template specializations are not hidden with fvisibility=hidden Date: Fri, 23 Feb 2024 13:40:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: visibility 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: cc Message-ID: In-Reply-To: References: 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=3D105645 Julian Waters changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tanksherman27 at gmail dot= com --- Comment #3 from Julian Waters --- I can confirm this on gcc 11 and higher: #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) Is this enough of a reproducer to get this confirmed?=