summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/bits/shared_ptr_base.h
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-29 21:33:29 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-29 21:33:29 +0000
commitcc18a6982f1c80afada005eba9d3b5ff9697fa28 (patch)
tree0a91ae3bd7a3a6ab1173d9fd2aef6e767e51e482 /libstdc++-v3/include/bits/shared_ptr_base.h
parentd601e3726d2cec94429c6a2ef1f5fc940264e99b (diff)
downloadppe42-gcc-cc18a6982f1c80afada005eba9d3b5ff9697fa28.tar.gz
ppe42-gcc-cc18a6982f1c80afada005eba9d3b5ff9697fa28.zip
PR libstdc++/58839
* include/bits/shared_ptr_base.h (__shared_ptr<T>::__shared_ptr(unique_ptr<U,D>&&)): Only use addressof when unique_ptr<U,D>::pointer is not a built-in pointer type. * testsuite/20_util/shared_ptr/cons/58839.cc: New. * testsuite/20_util/enable_shared_from_this/members/assign.cc: New. * testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204184 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/shared_ptr_base.h')
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 911dd928c0b..91b63677b73 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -855,9 +855,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_ptr(__r.get()), _M_refcount()
{
__glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
- auto __tmp = std::__addressof(*__r.get());
+ auto __raw = _S_raw_ptr(__r.get());
_M_refcount = __shared_count<_Lp>(std::move(__r));
- __enable_shared_from_this_helper(_M_refcount, __tmp, __tmp);
+ __enable_shared_from_this_helper(_M_refcount, __raw, __raw);
}
#if _GLIBCXX_USE_DEPRECATED
@@ -1048,6 +1048,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_get_deleter(const std::type_info& __ti) const noexcept
{ return _M_refcount._M_get_deleter(__ti); }
+ template<typename _Tp1>
+ static _Tp1*
+ _S_raw_ptr(_Tp1* __ptr)
+ { return __ptr; }
+
+ template<typename _Tp1>
+ static auto
+ _S_raw_ptr(_Tp1 __ptr) -> decltype(std::__addressof(*__ptr))
+ { return std::__addressof(*__ptr); }
+
template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr;
template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr;
OpenPOWER on IntegriCloud