The old version of _Sp_counted_ptr_inplace::_M_get_deleter (up to GCC 8.2.0) expects to be passed a real std::typeinfo object, so mixing that with the new definition of the __shared_ptr constructor (which always passes the fake tag) leads to accessing the fake object as a real std::typeinfo. Instead of trying to make it safe to mix the old and new definitions, just stop using that function. By passing a reference to __shared_ptr::_M_ptr to the __shared_count constructor it can be set directly, without needing to obtain the pointer via the _M_get_deleter back-channel. This avoids a virtual dispatch (which fixes PR 87514). This means that code built against new libstdc++ headers doesn't use _M_get_deleter at all, and so make_shared works the same whether RTTI is enabled or not. Also change _M_get_deleter so that it checks for a real type_info object even when RTTI is disabled, by calling a library function. Unless libstdc++ itself is built without RTTI that library function will be able to test if it's the right type_info. This means the new definition of _M_get_deleter can handle both the fake type_info tag and a real type_info object, even if built without RTTI. If linking to objects built against older versions of libstdc++ then if all objects use -frtti or all use -fno-rtti, then the caller of _M_get_deleter and the definition of _M_get_deleter will be consistent and it will work. If mixing -frtti with -fno-rtti it can still fail if the linker picks an old definition of _M_get_deleter and an old __shared_ptr constructor that are incompatible. In that some or all objects might need to be recompiled. PR libstdc++/87514 PR libstdc++/87520 PR libstdc++/88782 * config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export new symbol. * include/bits/shared_ptr.h (shared_ptr(_Sp_make_shared_tag, const Alloc&, Args&&...)) (allocate_shared): Change to use new tag type. * include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_eq): Declare new member function. (_Sp_alloc_shared_tag): Define new type. (_Sp_counted_ptr_inplace): Declare __shared_count<_Lp> as a friend. (_Sp_counted_ptr_inplace::_M_get_deleter) [!__cpp_rtti]: Use _Sp_make_shared_tag::_S_eq to check type_info. (__shared_count(Ptr, Deleter),__shared_count(Ptr, Deleter, Alloc)): Constrain to prevent being called with _Sp_alloc_shared_tag. (__shared_count(_Sp_make_shared_tag, const _Alloc&, Args&&...)): Replace constructor with ... (__shared_count(Tp*&, _Sp_alloc_shared_tag<_Alloc>, Args&&...)): Use reference parameter so address of the new object can be returned to the caller. Obtain the allocator from the tag type. (__shared_ptr(_Sp_make_shared_tag, const Alloc&, Args&&...)): Replace constructor with ... (__shared_ptr(_Sp_alloc_shared_tag<Alloc>, Args&&...)): Pass _M_ptr to the __shared_count constructor. (__allocate_shared): Change to use new tag type. * src/c++11/shared_ptr.cc (_Sp_make_shared_tag::_S_eq): Define. From-SVN: r268086
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| Makefile.am | Loading commit data... | |
| Makefile.in | Loading commit data... | |
| chrono.cc | Loading commit data... | |
| codecvt.cc | Loading commit data... | |
| compatibility-atomic-c++0x.cc | Loading commit data... | |
| compatibility-c++0x.cc | Loading commit data... | |
| compatibility-chrono.cc | Loading commit data... | |
| compatibility-condvar.cc | Loading commit data... | |
| compatibility-thread-c++0x.cc | Loading commit data... | |
| condition_variable.cc | Loading commit data... | |
| cow-fstream-inst.cc | Loading commit data... | |
| cow-locale_init.cc | Loading commit data... | |
| cow-shim_facets.cc | Loading commit data... | |
| cow-sstream-inst.cc | Loading commit data... | |
| cow-stdexcept.cc | Loading commit data... | |
| cow-string-inst.cc | Loading commit data... | |
| cow-string-io-inst.cc | Loading commit data... | |
| cow-wstring-inst.cc | Loading commit data... | |
| cow-wstring-io-inst.cc | Loading commit data... | |
| ctype.cc | Loading commit data... | |
| cxx11-hash_tr1.cc | Loading commit data... | |
| cxx11-ios_failure.cc | Loading commit data... | |
| cxx11-locale-inst.cc | Loading commit data... | |
| cxx11-shim_facets.cc | Loading commit data... | |
| cxx11-stdexcept.cc | Loading commit data... | |
| cxx11-wlocale-inst.cc | Loading commit data... | |
| debug.cc | Loading commit data... | |
| ext11-inst.cc | Loading commit data... | |
| fstream-inst.cc | Loading commit data... | |
| functexcept.cc | Loading commit data... | |
| functional.cc | Loading commit data... | |
| futex.cc | Loading commit data... | |
| future.cc | Loading commit data... | |
| hash_c++0x.cc | Loading commit data... | |
| hashtable_c++0x.cc | Loading commit data... | |
| ios-inst.cc | Loading commit data... | |
| ios.cc | Loading commit data... | |
| iostream-inst.cc | Loading commit data... | |
| istream-inst.cc | Loading commit data... | |
| limits.cc | Loading commit data... | |
| locale-inst.cc | Loading commit data... | |
| mutex.cc | Loading commit data... | |
| mutex_pool.h | Loading commit data... | |
| ostream-inst.cc | Loading commit data... | |
| placeholders.cc | Loading commit data... | |
| random.cc | Loading commit data... | |
| regex.cc | Loading commit data... | |
| shared_ptr.cc | Loading commit data... | |
| snprintf_lite.cc | Loading commit data... | |
| sso_string.cc | Loading commit data... | |
| sstream-inst.cc | Loading commit data... | |
| streambuf-inst.cc | Loading commit data... | |
| string-inst.cc | Loading commit data... | |
| string-io-inst.cc | Loading commit data... | |
| system_error.cc | Loading commit data... | |
| thread.cc | Loading commit data... | |
| wlocale-inst.cc | Loading commit data... | |
| wstring-inst.cc | Loading commit data... | |
| wstring-io-inst.cc | Loading commit data... |