From 1d752b4feec13afaae5ad9f6d24c0f4d83d674e1 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 8 Dec 2016 13:25:03 +0000 Subject: [PATCH] Delete std::swap for debug mode array * include/debug/array (swap): Add deleted overload. * include/bits/stl_pair.h (swap): Remove redundant inline keyword from deleted overload. * include/bits/unique_ptr.h (swap): Likewise. * include/std/array (swap): Likewise. * include/std/optional (swap): Likewise. * include/std/tuple (swap): Likewise. * include/std/variant (swap): Likewise. * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise. * testsuite/23_containers/array/tuple_interface/ tuple_element_debug_neg.cc: Likewise. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: Likewise. From-SVN: r243437 --- libstdc++-v3/ChangeLog | 16 ++++++++++++++++ libstdc++-v3/include/bits/stl_pair.h | 1 - libstdc++-v3/include/bits/unique_ptr.h | 1 - libstdc++-v3/include/debug/array | 8 ++++++++ libstdc++-v3/include/std/array | 1 - libstdc++-v3/include/std/optional | 2 +- libstdc++-v3/include/std/tuple | 1 - libstdc++-v3/include/std/variant | 4 ++-- .../array/tuple_interface/get_debug_neg.cc | 4 ++-- .../array/tuple_interface/get_neg.cc | 6 +++--- .../tuple_interface/tuple_element_debug_neg.cc | 2 +- .../array/tuple_interface/tuple_element_neg.cc | 2 +- 12 files changed, 34 insertions(+), 14 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 42b02a072ff..084f0d78a7d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,21 @@ 2016-12-08 Jonathan Wakely + * include/debug/array (swap): Add deleted overload. + * include/bits/stl_pair.h (swap): Remove redundant inline keyword + from deleted overload. + * include/bits/unique_ptr.h (swap): Likewise. + * include/std/array (swap): Likewise. + * include/std/optional (swap): Likewise. + * include/std/tuple (swap): Likewise. + * include/std/variant (swap): Likewise. + * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: + Adjust dg-error line numbers. + * testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise. + * testsuite/23_containers/array/tuple_interface/ + tuple_element_debug_neg.cc: Likewise. + * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: + Likewise. + PR libstdc++/71856 * doc/xml/manual/using.xml: Document macro. * include/bits/c++config [_GLIBCXX_DEBUG || _GLIBCXX_PARALLEL] diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 981dbeb6875..01c71345bb2 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -481,7 +481,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template - inline typename enable_if, __is_swappable<_T2>>::value>::type swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 03f9bfc7d1f..56e6ec0b2c7 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -652,7 +652,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template - inline typename enable_if::value>::type swap(unique_ptr<_Tp, _Dp>&, unique_ptr<_Tp, _Dp>&) = delete; diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array index 48ab2fdf120..63e680897da 100644 --- a/libstdc++-v3/include/debug/array +++ b/libstdc++-v3/include/debug/array @@ -260,6 +260,14 @@ namespace __debug { return !(__one < __two); } // Specialized algorithms. + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if< + !_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type + swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; +#endif + template inline void swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index fa7bac6cfbe..f5028c98994 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -290,7 +290,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template - inline typename enable_if< !_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 191d64ba902..3d69e104199 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -930,7 +930,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __lhs.swap(__rhs); } template - inline enable_if_t && is_swappable_v<_Tp>)> + enable_if_t && is_swappable_v<_Tp>)> swap(optional<_Tp>&, optional<_Tp>&) = delete; template diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index fb2fd177aee..13e0bf8e3cf 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -1588,7 +1588,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template - inline typename enable_if...>::value>::type swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; #endif diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index dd6109dc046..822674ffbec 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -865,8 +865,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __lhs.swap(__rhs); } template - inline enable_if_t..., - is_swappable<_Types>...>::value> + enable_if_t..., + is_swappable<_Types>...>::value> swap(variant<_Types...>&, variant<_Types...>&) = delete; class bad_variant_access : public exception diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc index 6ad09d6ac24..16761d31aa8 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc @@ -27,6 +27,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 *-*-* } 273 } -// { dg-error "static assertion failed" "" { target *-*-* } 282 } +// { dg-error "static assertion failed" "" { target *-*-* } 281 } // { dg-error "static assertion failed" "" { target *-*-* } 290 } +// { dg-error "static assertion failed" "" { target *-*-* } 298 } 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 568ec850a39..69d638b7c5e 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 @@ -27,6 +27,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 *-*-* } 303 } -// { dg-error "static assertion failed" "" { target *-*-* } 312 } -// { dg-error "static assertion failed" "" { target *-*-* } 320 } +// { dg-error "static assertion failed" "" { target *-*-* } 302 } +// { dg-error "static assertion failed" "" { target *-*-* } 311 } +// { dg-error "static assertion failed" "" { target *-*-* } 319 } diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc index d5ab406c3d2..1f3a5edc07e 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc @@ -22,4 +22,4 @@ typedef std::tuple_element<1, std::array>::type type; -// { dg-error "static assertion failed" "" { target *-*-* } 308 } +// { dg-error "static assertion failed" "" { target *-*-* } 316 } 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 32cb10b7dc2..016c7478f21 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 @@ -22,4 +22,4 @@ typedef std::tuple_element<1, std::array>::type type; -// { dg-error "static assertion failed" "" { target *-*-* } 351 } +// { dg-error "static assertion failed" "" { target *-*-* } 350 } -- 2.30.2