Prevent __uses_alloc from holding dangling references
* include/bits/uses_allocator.h (__use_alloc(const _Alloc&&)): Add deleted overload to prevent dangling references to rvalues. * include/experimental/memory_resource (polymorphic_allocator::construct): Do not call __use_alloc with rvalue arguments. From-SVN: r250019
This commit is contained in:
parent
68d872d728
commit
318c48e304
@ -1,3 +1,11 @@
|
|||||||
|
2017-07-06 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/uses_allocator.h (__use_alloc(const _Alloc&&)): Add
|
||||||
|
deleted overload to prevent dangling references to rvalues.
|
||||||
|
* include/experimental/memory_resource
|
||||||
|
(polymorphic_allocator::construct): Do not call __use_alloc with
|
||||||
|
rvalue arguments.
|
||||||
|
|
||||||
2017-06-27 Tim Shen <timshen@google.com>
|
2017-06-27 Tim Shen <timshen@google.com>
|
||||||
|
|
||||||
PR libstdc++/80187
|
PR libstdc++/80187
|
||||||
|
@ -109,6 +109,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
__ret._M_a = std::__addressof(__a);
|
__ret._M_a = std::__addressof(__a);
|
||||||
return __ret;
|
return __ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
||||||
|
void
|
||||||
|
__use_alloc(const _Alloc&&) = delete;
|
||||||
|
|
||||||
#if __cplusplus > 201402L
|
#if __cplusplus > 201402L
|
||||||
template <typename _Tp, typename _Alloc>
|
template <typename _Tp, typename _Alloc>
|
||||||
inline constexpr bool uses_allocator_v =
|
inline constexpr bool uses_allocator_v =
|
||||||
|
@ -168,8 +168,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
template <typename _Tp1, typename... _Args> //used here
|
template <typename _Tp1, typename... _Args> //used here
|
||||||
void construct(_Tp1* __p, _Args&&... __args)
|
void construct(_Tp1* __p, _Args&&... __args)
|
||||||
{
|
{
|
||||||
auto __use_tag = __use_alloc<_Tp1, memory_resource*,
|
memory_resource* const __resource = this->resource();
|
||||||
_Args...>(this->resource());
|
auto __use_tag
|
||||||
|
= __use_alloc<_Tp1, memory_resource*, _Args...>(__resource);
|
||||||
_M_construct(__use_tag, __p, std::forward<_Args>(__args)...);
|
_M_construct(__use_tag, __p, std::forward<_Args>(__args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,10 +181,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
tuple<_Args1...> __x,
|
tuple<_Args1...> __x,
|
||||||
tuple<_Args2...> __y)
|
tuple<_Args2...> __y)
|
||||||
{
|
{
|
||||||
|
memory_resource* const __resource = this->resource();
|
||||||
auto __x_use_tag =
|
auto __x_use_tag =
|
||||||
__use_alloc<_Tp1, memory_resource*, _Args1...>(this->resource());
|
__use_alloc<_Tp1, memory_resource*, _Args1...>(__resource);
|
||||||
auto __y_use_tag =
|
auto __y_use_tag =
|
||||||
__use_alloc<_Tp2, memory_resource*, _Args2...>(this->resource());
|
__use_alloc<_Tp2, memory_resource*, _Args2...>(__resource);
|
||||||
|
|
||||||
::new(__p) std::pair<_Tp1, _Tp2>(piecewise_construct,
|
::new(__p) std::pair<_Tp1, _Tp2>(piecewise_construct,
|
||||||
_M_construct_p(__x_use_tag, __x),
|
_M_construct_p(__x_use_tag, __x),
|
||||||
|
Loading…
Reference in New Issue
Block a user