public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kndevl at outlook dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105645] New: Template specializations are not hidden with fvisibility=hidden Date: Wed, 18 May 2022 14:02:57 +0000 [thread overview] Message-ID: <bug-105645-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105645 Bug ID: 105645 Summary: Template specializations are not hidden with fvisibility=hidden Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kndevl at outlook dot com Target Milestone: --- Consider this snippet `encoding.cpp` ``` namespace Test { enum class Encoding { A, B }; template <Encoding enc> int encode(int); template <> int encode<Encoding::A>(int x) { return x + 1; } int f() { return 42; } } ``` I am compiling it through CMake with `/usr/bin/g++ -Dencoding_EXPORTS -g -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -std=gnu++17 -MD -MT CMakeFiles/encoding.dir/encoding.cpp.o -MF CMakeFiles/encoding.dir/encoding.cpp.o.d -o CMakeFiles/encoding.dir/encoding.cpp.o -c /home/nishanth/source/main/encoding.cpp` and linking it with `/usr/bin/g++ -fPIC -g -shared -Wl,-soname,libencoding.so -o libencoding.so CMakeFiles/encoding.dir/encoding.cpp.o CMakeFiles/encoding.dir/encoding-user.cpp.o` I expect `f()` and `Test::encode<Encoding::A>` to have the same symbol binding in `libencoding.so`. This is the output of `nm -C libencoding.so` ``` 0000000000001118 t Test::f() 0000000000001109 T int Test::encode<(Test::Encoding)0>(int) ``` `objdump -t encoding.cpp.o` does not have a `.hidden` tag on the `encode` specialization ``` 0000000000000000 g F .text 000000000000000f _ZN4Test6encodeILNS_8EncodingE0EEEii 000000000000000f g F .text 000000000000000b .hidden _ZN4Test1fEv ``` I can make `Test::encode` specialization local only by using `__attribute__((visibility("hidden")))` explicitly on the definition, in addition to calling the compiler with `-fvisibility=hidden`. On the other hand, clang 13.0.1 marks both `f()` and the `encode` specialization with `.hidden` in `objdump -t` output. Is there a way I can force g++ to hide template specializations?
next reply other threads:[~2022-05-18 14:02 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-18 14:02 kndevl at outlook dot com [this message] 2022-05-18 14:25 ` [Bug c++/105645] " pinskia at gcc dot gnu.org 2022-05-19 6:10 ` kndevl at outlook dot com 2024-02-23 13:40 ` tanksherman27 at gmail dot com 2024-05-26 7:43 ` pinskia at gcc dot gnu.org 2024-05-26 7:48 ` tanksherman27 at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105645-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).