public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types
@ 2022-03-08 8:07 alex.wabik at gmail dot com
2022-03-08 8:12 ` [Bug c++/104834] " alex.wabik at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: alex.wabik at gmail dot com @ 2022-03-08 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834
Bug ID: 104834
Summary: visibility=hidden ignored for template instantiations
for certain dependent types
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alex.wabik at gmail dot com
Target Milestone: ---
Created attachment 52579
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52579&action=edit
Testcase
Public visibility templates generate instances with public visiblity if a
template parameter is an enum or class enum declared in the translation unit
which uses -fvisibility=hidden, or even explicitly marked with hidden
visibility attribute.
This behaviour does not reproduce on clang, which will only instantiate public
template if the enum has attribute visibility=default, otherwise the
instantiated template has hidden visibility.
The std::thread's constructor instantiates the std::thread::_State_impl type,
which generates functions with default visibility if std::thread is constructed
with a lambda defined in the hidden-visiblity class. This behaviour also does
not reproduce on clang.
I have also seen similar problems with std::function's template constructor,
and with future base instantiations when using std::async, but I was not able
to produce a minimal testcase; The testcase I attach demonstrates the problem
for enums and std::thread only.
The workaround for the enum problem and the lambda problem is to define these
types in the anonymous namespace.
Attaching the test code. Inspecting the compiled object reveals the following
default visibility symbols, which I believe should be hidden:
std::thread::_State_impl<std::thread::_Invoker<std::tuple<ThreadTest::ThreadTest()::{lambda()#1}>
> >::~_State_impl() where the whole ThreadTest class has hidden visibility.
aaa::Wrapper<ThisIsEnum>::get() where the ThisIsEnum type is an enum with
hidden visibility.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/104834] visibility=hidden ignored for template instantiations for certain dependent types 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com @ 2022-03-08 8:12 ` alex.wabik at gmail dot com 2022-03-08 8:26 ` pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: alex.wabik at gmail dot com @ 2022-03-08 8:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834 --- Comment #1 from Aleksander Wabik <alex.wabik at gmail dot com> --- Default visiblity symbols in the object file generated by the compilation: - in GCC: $ readelf -sW test.o | grep -v UND | grep -v SECTION | grep DEFAULT 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.cc 10: 0000000000000000 40 FUNC LOCAL DEFAULT 21 _Z7PubFuncv.cold 30: 0000000000000000 0 NOTYPE LOCAL DEFAULT 2 _ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJZN10ThreadTestC4EvEUlvE_EEEEED5Ev 46: 0000000000000000 40 OBJECT WEAK DEFAULT 31 _ZTVNSt6thread11_State_implINS_8_InvokerISt5tupleIJZN10ThreadTestC4EvEUlvE_EEEEEE 51: 0000000000000000 127 FUNC GLOBAL DEFAULT 12 _Z7PubFuncv 60: 0000000000000000 4 FUNC WEAK DEFAULT 24 _ZN3aaa7WrapperI12PublicStructE3getEv 62: 0000000000000000 4 FUNC WEAK DEFAULT 26 _ZN3aaa7WrapperI10ThisIsEnumE3getEv 63: 0000000000000000 4 FUNC WEAK DEFAULT 27 _ZN3aaa7WrapperI10PublicEnumE3getEv - in clang: $ readelf -sW test.o | grep -v UND | grep -v SECTION | grep DEFAULT 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.cc 2: 0000000000000000 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table0 21: 0000000000000000 151 FUNC GLOBAL DEFAULT 2 _Z7PubFuncv 22: 0000000000000000 4 FUNC WEAK DEFAULT 12 _ZN3aaa7WrapperI10PublicEnumE3getEv 25: 0000000000000000 4 FUNC WEAK DEFAULT 6 _ZN3aaa7WrapperI12PublicStructE3getEv ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/104834] visibility=hidden ignored for template instantiations for certain dependent types 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com 2022-03-08 8:12 ` [Bug c++/104834] " alex.wabik at gmail dot com @ 2022-03-08 8:26 ` pinskia at gcc dot gnu.org 2022-03-08 8:27 ` rguenth at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-03-08 8:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note I think it is the vtable for std::thread::_State_impl which looks broken and not the deconstructor. Note I think there are different issues here too and not really related to another one. The enum issue is seperate from the vtable issue. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/104834] visibility=hidden ignored for template instantiations for certain dependent types 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com 2022-03-08 8:12 ` [Bug c++/104834] " alex.wabik at gmail dot com 2022-03-08 8:26 ` pinskia at gcc dot gnu.org @ 2022-03-08 8:27 ` rguenth at gcc dot gnu.org 2022-03-08 8:27 ` rguenth at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-03-08 8:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834 --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. Note that when not optimizing clang also gets you 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.cc 2: 0000000000000000 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table0 3: 0000000000000010 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table11 4: 0000000000000028 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table15 5: 000000000000003c 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table16 6: 0000000000000050 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table18 7: 0000000000000064 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table37 8: 0000000000000078 0 NOTYPE LOCAL DEFAULT 4 GCC_except_table47 69: 0000000000000000 78 FUNC GLOBAL DEFAULT 2 _Z7PubFuncv 73: 0000000000000000 14 FUNC WEAK DEFAULT 21 _ZN3aaa7WrapperI10PublicEnumE3getEv 76: 0000000000000000 14 FUNC WEAK DEFAULT 15 _ZN3aaa7WrapperI12PublicStructE3getEv 116: 0000000000000000 27 FUNC WEAK DEFAULT 121 _ZSt12__get_helperILm0EPNSt6thread6_StateEJSt14default_deleteIS1_EEERT0_RSt11_Tuple_implIXT_EJS5_DpT1_EE 118: 0000000000000000 27 FUNC WEAK DEFAULT 142 _ZSt12__get_helperILm1ESt14default_deleteINSt6thread6_StateEEJEERT0_RSt11_Tuple_implIXT_EJS4_DpT1_EE 120: 0000000000000000 30 FUNC WEAK DEFAULT 118 _ZSt3getILm0EJPNSt6thread6_StateESt14default_deleteIS1_EEERNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeERS9_ 122: 0000000000000000 30 FUNC WEAK DEFAULT 139 _ZSt3getILm1EJPNSt6thread6_StateESt14default_deleteIS1_EEERNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeERS9_ 123: 0000000000000000 14 FUNC WEAK DEFAULT 134 _ZSt4moveIRPNSt6thread6_StateEEONSt16remove_referenceIT_E4typeEOS5_ 128: 0000000000000000 31 FUNC WEAK DEFAULT 156 _ZSteqNSt6thread2idES0_ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/104834] visibility=hidden ignored for template instantiations for certain dependent types 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com ` (2 preceding siblings ...) 2022-03-08 8:27 ` rguenth at gcc dot gnu.org @ 2022-03-08 8:27 ` rguenth at gcc dot gnu.org 2022-03-08 8:28 ` pinskia at gcc dot gnu.org 2022-03-08 8:35 ` alex.wabik at gmail dot com 5 siblings, 0 replies; 7+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-03-08 8:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-03-08 Known to fail| |11.2.0, 12.0, 7.5.0 Keywords| |ABI ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/104834] visibility=hidden ignored for template instantiations for certain dependent types 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com ` (3 preceding siblings ...) 2022-03-08 8:27 ` rguenth at gcc dot gnu.org @ 2022-03-08 8:28 ` pinskia at gcc dot gnu.org 2022-03-08 8:35 ` alex.wabik at gmail dot com 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-03-08 8:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Oh also the deconstructor has a local symbol so can be safely ignored. But the vtable is the bug though. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/104834] visibility=hidden ignored for template instantiations for certain dependent types 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com ` (4 preceding siblings ...) 2022-03-08 8:28 ` pinskia at gcc dot gnu.org @ 2022-03-08 8:35 ` alex.wabik at gmail dot com 5 siblings, 0 replies; 7+ messages in thread From: alex.wabik at gmail dot com @ 2022-03-08 8:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104834 --- Comment #5 from Aleksander Wabik <alex.wabik at gmail dot com> --- (In reply to Andrew Pinski from comment #2) > The enum issue is seperate from the vtable issue. Should I create separate bug for that then? ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-03-08 8:35 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-08 8:07 [Bug c++/104834] New: visibility=hidden ignored for template instantiations for certain dependent types alex.wabik at gmail dot com 2022-03-08 8:12 ` [Bug c++/104834] " alex.wabik at gmail dot com 2022-03-08 8:26 ` pinskia at gcc dot gnu.org 2022-03-08 8:27 ` rguenth at gcc dot gnu.org 2022-03-08 8:27 ` rguenth at gcc dot gnu.org 2022-03-08 8:28 ` pinskia at gcc dot gnu.org 2022-03-08 8:35 ` alex.wabik at gmail dot com
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).