This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
clang (including trunk and many older versions) incorrectly marks static local variables (__tag) hidden when -fvisibility-inlines-hidden is used. % cat b.cc #include <memory> std::shared_ptr<int> foo(int x) { return std::make_shared<int>(x); } % g++-8 -fvisibility-inlines-hidden -fno-rtti -c b.cc % readelf -s b.o | grep _S_ti 163: 0000000000000000 1 OBJECT UNIQUE DEFAULT 67 _ZZNSt19_Sp_make_shared_tag5_S_tiEvE5__tag 164: 0000000000000000 8 FUNC WEAK HIDDEN 68 _ZNSt19_Sp_make_shared_tag5_S_tiEv % ~/Dev/llvm/static-release/bin/clang++ -fvisibility-inlines-hidden -fno-rtti -c b.cc % readelf -s b.o | grep _S_ti 129: 0000000000000000 16 FUNC WEAK HIDDEN 34 _ZNSt19_Sp_make_shared_tag5_S_tiEv 155: 0000000000000000 1 OBJECT WEAK HIDDEN 202 _ZZNSt19_Sp_make_shared_tag5_S_tiEvE5__tag This can lead to multiple instances of __tag when shares objects are used. The function virtual void* std::_Sp_counted_ptr_inplace::_M_get_deleter(const std::type_info& __ti) noexcept may return nullptr and causes std::make_shared<T>() to return nullptr (-fvisibility-inlines-hidden -fno-rtti). After applying this patch (tagging _S_ti() with default visibility to override -fvisibility-inlines-hidden) % readelf -s b.o | grep _S_ti 129: 0000000000000000 16 FUNC WEAK DEFAULT 34 _ZNSt19_Sp_make_shared_tag5_S_tiEv 155: 0000000000000000 1 OBJECT WEAK DEFAULT 202 _ZZNSt19_Sp_make_shared_tag5_S_tiEvE5__tag This issue caused 10+ check-all tests of a -DUSE_SHARED_LLVM=On build of llvm (compiled with clang trunk) to SIGSEGV (because std::make_shared returned nullptr) and this patch fixes it. * include/bits/shared_ptr_base.h (_S_ti): Use _GLIBCXX_VISIBILITY(default) -- 宋方睿
Attachment:
patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |