forked from OSchip/llvm-project
[libc++] Fix unqualified call to 'ref' inside shared_ptr(unique_ptr<U, D>)
This prevents unintended ADL: https://gcc.godbolt.org/z/EHw3Gy This issue was mentioned as an addendum in PR44398. Differential Revision: https://reviews.llvm.org/D74289
This commit is contained in:
parent
e442f38395
commit
092a57f508
|
@ -4174,7 +4174,7 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
|
|||
typedef __shared_ptr_pointer<_Yp*,
|
||||
reference_wrapper<typename remove_reference<_Dp>::type>,
|
||||
_AllocT > _CntrlBlk;
|
||||
__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), _AllocT());
|
||||
__cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
|
||||
__enable_weak_this(__r.get(), __r.get());
|
||||
}
|
||||
__r.release();
|
||||
|
|
|
@ -49,6 +49,13 @@ void fn ( const std::shared_ptr<B> &) { assert (false); }
|
|||
template <typename T>
|
||||
void assert_deleter ( T * ) { assert(false); }
|
||||
|
||||
namespace adl {
|
||||
struct D {
|
||||
void operator()(int *) const {}
|
||||
};
|
||||
void ref(D);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
|
@ -98,5 +105,11 @@ int main(int, char**)
|
|||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
adl::D d;
|
||||
std::unique_ptr<int, adl::D&> u(nullptr, d);
|
||||
std::shared_ptr<int> s = std::move(u);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue