summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-28 11:53:35 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-28 11:53:35 +0000
commitfcf3dfea99c627dcfa1f8ca146540be50fa829c9 (patch)
tree912327d569a87f082f053ae344dbfd4bcbe2f58d /libstdc++-v3
parent86181b33ad38752d875680911e57e2fb25e34dc7 (diff)
downloadgcc-fcf3dfea99c627dcfa1f8ca146540be50fa829c9.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223806 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/std/array12
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc4
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc2
4 files changed, 23 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index cadee8312b4..aea089adef8 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,13 @@
+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.
+
2015-05-27 Jonathan Wakely <jwakely@redhat.com>
* include/bits/stl_tree.h (_Rb_tree::_M_end()): Return _Base_ptr
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index 429506b3850..24be44f5b13 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -51,6 +51,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
static constexpr _Tp&
_S_ref(const _Type& __t, std::size_t __n) noexcept
{ return const_cast<_Tp&>(__t[__n]); }
+
+ static constexpr _Tp*
+ _S_ptr(const _Type& __t) noexcept
+ { return const_cast<_Tp*>(__t); }
};
template<typename _Tp>
@@ -61,6 +65,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
static constexpr _Tp&
_S_ref(const _Type&, std::size_t) noexcept
{ return *static_cast<_Tp*>(nullptr); }
+
+ static constexpr _Tp*
+ _S_ptr(const _Type&) noexcept
+ { return nullptr; }
};
/**
@@ -219,11 +227,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
pointer
data() noexcept
- { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+ { return _AT_Type::_S_ptr(_M_elems); }
const_pointer
data() const noexcept
- { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+ { return _AT_Type::_S_ptr(_M_elems); }
};
// Array comparisons.
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
index 76044125fa3..68309645317 100644
--- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
@@ -28,6 +28,6 @@ int n1 = std::get<1>(a);
int n2 = std::get<1>(std::move(a));
int n3 = std::get<1>(ca);
-// { dg-error "static assertion failed" "" { target *-*-* } 274 }
-// { dg-error "static assertion failed" "" { target *-*-* } 283 }
+// { dg-error "static assertion failed" "" { target *-*-* } 282 }
// { dg-error "static assertion failed" "" { target *-*-* } 291 }
+// { dg-error "static assertion failed" "" { target *-*-* } 299 }
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
index 9788053a9b1..5d75366611c 100644
--- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
@@ -23,4 +23,4 @@
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 }