mirror of git://gcc.gnu.org/git/gcc.git
re PR libstdc++/65352 (array<T,0>::begin()/end() etc. forms a null reference and breaks on clang+ubsan)
PR libstdc++/65352 * include/std/array (__array_traits::_S_ptr): New function. (array::data): Use _S_ptr to avoid creating invalid reference. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: likewise. From-SVN: r223812
This commit is contained in:
parent
d6819d26ad
commit
62a1e40981
|
|
@ -1,5 +1,13 @@
|
||||||
2015-05-28 Jonathan Wakely <jwakely@redhat.com>
|
2015-05-28 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
PR libstdc++/65352
|
||||||
|
* include/std/array (__array_traits::_S_ptr): New function.
|
||||||
|
(array::data): Use _S_ptr to avoid creating invalid reference.
|
||||||
|
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust
|
||||||
|
dg-error line numbers.
|
||||||
|
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
|
||||||
|
likewise.
|
||||||
|
|
||||||
PR libstdc++/66017
|
PR libstdc++/66017
|
||||||
* include/bits/stl_tree.h (_Rb_tree_node): Use __aligned_membuf.
|
* include/bits/stl_tree.h (_Rb_tree_node): Use __aligned_membuf.
|
||||||
(_Rb_tree_iterator, _Rb_tree_const_iterator): Support construction
|
(_Rb_tree_iterator, _Rb_tree_const_iterator): Support construction
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||||
static constexpr _Tp&
|
static constexpr _Tp&
|
||||||
_S_ref(const _Type& __t, std::size_t __n) noexcept
|
_S_ref(const _Type& __t, std::size_t __n) noexcept
|
||||||
{ return const_cast<_Tp&>(__t[__n]); }
|
{ return const_cast<_Tp&>(__t[__n]); }
|
||||||
|
|
||||||
|
static constexpr _Tp*
|
||||||
|
_S_ptr(const _Type& __t) noexcept
|
||||||
|
{ return const_cast<_Tp*>(__t); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
|
|
@ -61,6 +65,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||||
static constexpr _Tp&
|
static constexpr _Tp&
|
||||||
_S_ref(const _Type&, std::size_t) noexcept
|
_S_ref(const _Type&, std::size_t) noexcept
|
||||||
{ return *static_cast<_Tp*>(nullptr); }
|
{ return *static_cast<_Tp*>(nullptr); }
|
||||||
|
|
||||||
|
static constexpr _Tp*
|
||||||
|
_S_ptr(const _Type&) noexcept
|
||||||
|
{ return nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -219,11 +227,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||||
|
|
||||||
pointer
|
pointer
|
||||||
data() noexcept
|
data() noexcept
|
||||||
{ return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
|
{ return _AT_Type::_S_ptr(_M_elems); }
|
||||||
|
|
||||||
const_pointer
|
const_pointer
|
||||||
data() const noexcept
|
data() const noexcept
|
||||||
{ return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
|
{ return _AT_Type::_S_ptr(_M_elems); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Array comparisons.
|
// Array comparisons.
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,6 @@ int n1 = std::get<1>(a);
|
||||||
int n2 = std::get<1>(std::move(a));
|
int n2 = std::get<1>(std::move(a));
|
||||||
int n3 = std::get<1>(ca);
|
int n3 = std::get<1>(ca);
|
||||||
|
|
||||||
// { dg-error "static assertion failed" "" { target *-*-* } 274 }
|
// { dg-error "static assertion failed" "" { target *-*-* } 282 }
|
||||||
// { dg-error "static assertion failed" "" { target *-*-* } 283 }
|
|
||||||
// { dg-error "static assertion failed" "" { target *-*-* } 291 }
|
// { dg-error "static assertion failed" "" { target *-*-* } 291 }
|
||||||
|
// { dg-error "static assertion failed" "" { target *-*-* } 299 }
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,4 @@
|
||||||
|
|
||||||
typedef std::tuple_element<1, std::array<int, 1>>::type type;
|
typedef std::tuple_element<1, std::array<int, 1>>::type type;
|
||||||
|
|
||||||
// { dg-error "static assertion failed" "" { target *-*-* } 322 }
|
// { dg-error "static assertion failed" "" { target *-*-* } 330 }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue