@@ -185,11 +185,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3527. uses_allocator_construction_args handles rvalue pairs
+ // of rvalue references incorrectly
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a,
- std::move(__pr).first),
+ std::get<0>(std::move(__pr))),
std::uses_allocator_construction_args<_Tp2>(__a,
- std::move(__pr).second));
+ std::get<1>(std::move(__pr))));
}
#if __cplusplus > 202002L
@@ -216,9 +219,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a,
- std::move(__pr).first),
+ std::get<0>(std::move(__pr))),
std::uses_allocator_construction_args<_Tp2>(__a,
- std::move(__pr).second));
+ std::get<1>(std::move(__pr))));
}
#endif // C++23
new file mode 100644
@@ -0,0 +1,68 @@
+// { dg-do compile { target c++11 } }
+
+#include <utility>
+
+template<int N, typename T, typename Pair>
+constexpr bool
+check()
+{
+ return std::is_same<decltype(std::get<N>(std::declval<Pair>())), T>::value;
+}
+
+void
+test_value_category()
+{
+ using P = std::pair<int, long>;
+ static_assert( check<0, int&, P&>(),
+ "get<0>(pair<T1, T2>&)" );
+ static_assert( check<1, long&, P&>(),
+ "get<1>(pair<T1, T2>&)" );
+ static_assert( check<0, int&&, P&&>(),
+ "get<0>(pair<T1, T2>&&)" );
+ static_assert( check<1, long&&, P&&>(),
+ "get<1>(pair<T1, T2>&&)" );
+ static_assert( check<0, const int&, const P&>(),
+ "get<0>(const pair<T1, T2>&)" );
+ static_assert( check<1, const long&, const P&>(),
+ "get<1>(const pair<T1, T2>&)" );
+ static_assert( check<0, const int&&, const P&&>(),
+ "get<0>(const pair<T1, T2>&&)" );
+ static_assert( check<1, const long&&, const P&&>(),
+ "get<1>(const pair<T1, T2>&&)" );
+
+ using PL = std::pair<int&, long&>;
+ static_assert( check<0, int&, PL&>(),
+ "get<0>(pair<T1&, T2&>&)" );
+ static_assert( check<1, long&, PL&>(),
+ "get<1>(pair<T1&, T2&>&)" );
+ static_assert( check<0, int&, PL&&>(),
+ "get<0>(pair<T1&, T2&>&&)" );
+ static_assert( check<1, long&, PL&&>(),
+ "get<1>(pair<T1&, T2&>&&)" );
+ static_assert( check<0, int&, const PL&>(),
+ "get<0>(const pair<T1&, T2&>&)" );
+ static_assert( check<1, long&, const PL&>(),
+ "get<1>(const pair<T1&, T2&>&)" );
+ static_assert( check<0, int&, const PL&&>(),
+ "get<0>(const pair<T1&, T2&>&&)" );
+ static_assert( check<1, long&, const PL&&>(),
+ "get<1>(const pair<T1&, T2&>&&)" );
+
+ using PR = std::pair<int&&, long&&>;
+ static_assert( check<0, int&, P&>(),
+ "get<0>(pair<T1&&, T2&&>&)" );
+ static_assert( check<1, long&, P&>(),
+ "get<1>(pair<T1&&, T2&&>&)" );
+ static_assert( check<0, int&&, PR&&>(),
+ "get<0>(pair<T1&&, T2&&>&&)" );
+ static_assert( check<1, long&&, PR&&>(),
+ "get<1>(pair<T1&&, T2&&>&&)" );
+ static_assert( check<0, int&, const PR&>(),
+ "get<0>(const pair<T1&&, T2&&>&)" );
+ static_assert( check<1, long&, const PR&>(),
+ "get<1>(const pair<T1&&, T2&&>&)" );
+ static_assert( check<0, int&&, const PR&&>(),
+ "get<0>(const pair<T1&&, T2&&>&&)" );
+ static_assert( check<1, long&&, const PR&&>(),
+ "get<1>(const pair<T1&&, T2&&>&&)" );
+}
new file mode 100644
@@ -0,0 +1,23 @@
+// { dg-do compile { target c++11 } }
+
+#include <scoped_allocator>
+
+struct move_only
+{
+ move_only(move_only&&);
+};
+
+using P = std::pair<move_only, move_only>;
+
+void
+test_pr108952(std::pair<move_only&&, move_only&&> rvals)
+{
+ // LWG 3527. uses_allocator_construction_args handles rvalue pairs of
+ // rvalue references incorrectly.
+ // PR libstdc++/108952 Regression in uses_allocator_construction_args
+ // for pair of rvalue references
+ std::scoped_allocator_adaptor<std::allocator<P>> a;
+ auto p = a.allocate(1);
+ a.construct(p, std::move(rvals));
+ a.deallocate(p, 1);
+}
new file mode 100644
@@ -0,0 +1,22 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <memory>
+
+struct move_only
+{
+ move_only(move_only&&);
+};
+
+using P = std::pair<move_only, move_only>;
+
+void
+test_lwg3527(std::pair<move_only&&, move_only&&> rvals)
+{
+ // LWG 3527. uses_allocator_construction_args handles rvalue pairs of
+ // rvalue references incorrectly.
+ // PR libstdc++/108952 Regression in uses_allocator_construction_args
+ // for pair of rvalue references
+ std::allocator<move_only> a;
+ (void) std::uses_allocator_construction_args<P>(a, std::move(rvals));
+}