summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/20_util')
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/bad.cc15
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/cons.cc18
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/requirements.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/swap.cc12
-rw-r--r--libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc14
-rw-r--r--libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/optional/monadic/version.cc10
-rw-r--r--libstdc++-v3/testsuite/20_util/optional/requirements.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/optional/version.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/stacktrace/entry.cc53
-rw-r--r--libstdc++-v3/testsuite/20_util/stacktrace/synopsis.cc46
-rw-r--r--libstdc++-v3/testsuite/20_util/stacktrace/version.cc11
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/constexpr.cc48
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/comparison/constexpr.cc73
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc85
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/creation/constexpr.cc34
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/constexpr.cc68
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/constexpr.cc46
19 files changed, 417 insertions, 132 deletions
diff --git a/libstdc++-v3/testsuite/20_util/expected/bad.cc b/libstdc++-v3/testsuite/20_util/expected/bad.cc
new file mode 100644
index 00000000000..17bc6d69e88
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/expected/bad.cc
@@ -0,0 +1,15 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile }
+
+#include <expected>
+
+struct E {
+ E() = default;
+ E(E&&) = default;
+};
+
+void
+test_pr105146()
+{
+ std::bad_expected_access(E{});
+}
diff --git a/libstdc++-v3/testsuite/20_util/expected/cons.cc b/libstdc++-v3/testsuite/20_util/expected/cons.cc
index 1fe5b7bf4d1..6946858198c 100644
--- a/libstdc++-v3/testsuite/20_util/expected/cons.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/cons.cc
@@ -162,6 +162,22 @@ test_copy()
return true;
}
+constexpr bool
+test_pr105153()
+{
+ struct E {
+ E(int&&) = delete;
+ E(const int&);
+ };
+
+ std::expected<void, E> e(std::expected<void, int>{});
+
+ static_assert( ! std::is_constructible_v<std::expected<void, int>,
+ std::expected<int, int>> );
+
+ return true;
+}
+
int main()
{
test_default();
@@ -172,4 +188,6 @@ int main()
static_assert( test_err() );
test_copy();
static_assert( test_copy() );
+ test_pr105153();
+ static_assert( test_pr105153() );
}
diff --git a/libstdc++-v3/testsuite/20_util/expected/requirements.cc b/libstdc++-v3/testsuite/20_util/expected/requirements.cc
index 485aa338679..aae7059ef71 100644
--- a/libstdc++-v3/testsuite/20_util/expected/requirements.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/requirements.cc
@@ -124,6 +124,6 @@ static_assert( move_assignable< void, G > );
// QoI properties
static_assert( sizeof(std::expected<char, unsigned char>) == 2 );
static_assert( sizeof(std::expected<void, char>) == 2 );
-static_assert( sizeof(std::expected<void*, char>) == 2 * __alignof(void*) );
+static_assert( sizeof(std::expected<void*, char>) == sizeof(void*) + __alignof(void*) );
static_assert( alignof(std::expected<void, char>) == 1 );
static_assert( alignof(std::expected<void*, char>) == alignof(void*) );
diff --git a/libstdc++-v3/testsuite/20_util/expected/swap.cc b/libstdc++-v3/testsuite/20_util/expected/swap.cc
index 1b3b8c5f4e8..745db65fc6c 100644
--- a/libstdc++-v3/testsuite/20_util/expected/swap.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/swap.cc
@@ -27,19 +27,19 @@ test_swap()
VERIFY( e3.error() == 4 );
VERIFY( e4.error() == 3 );
- std::expected<int, int> v1(1), v2(2);
- std::expected<int, int> v3(std::unexpect, 3), v4(std::unexpect, 4);
+ std::expected<void, int> v1, v2;
+ std::expected<void, int> v3(std::unexpect, 3), v4(std::unexpect, 4);
swap(v1, v2);
- VERIFY( v1.value() == 2 );
- VERIFY( v2.value() == 1 );
+ VERIFY( v1.has_value() );
+ VERIFY( v2.has_value() );
swap(v1, v3);
VERIFY( ! v1.has_value() );
VERIFY( v1.error() == 3 );
- VERIFY( v3.value() == 2 );
+ VERIFY( v3.has_value() );
swap(v1, v3);
VERIFY( ! v3.has_value() );
- VERIFY( v1.value() == 2 );
+ VERIFY( v1.has_value() );
VERIFY( v3.error() == 3 );
swap(v3, v4);
VERIFY( ! v3.has_value() );
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc b/libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc
new file mode 100644
index 00000000000..cecb17e41cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc
@@ -0,0 +1,14 @@
+// { dg-do run { target c++17 } }
+
+#include <charconv>
+#include <string>
+
+int main()
+{
+ // PR libstdc++/105324
+ // std::from_chars() assertion at floating_from_chars.cc:78
+ std::string s(512, '1');
+ s[1] = '.';
+ long double d;
+ std::from_chars(s.data(), s.data() + s.size(), d);
+}
diff --git a/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc b/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc
index 7cbec330ea0..c7e54efafee 100644
--- a/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc
+++ b/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc
@@ -3,9 +3,7 @@
#include <optional>
-#ifndef __cpp_lib_monadic_optional
-# error "Feature test macro for monadic optional is missing in <optional>"
-#elif __cpp_lib_monadic_optional < 202110L
+#if __cpp_lib_optional < 202110L
# error "Feature test macro for monadic optional has wrong value in <optional>"
#endif
diff --git a/libstdc++-v3/testsuite/20_util/optional/monadic/version.cc b/libstdc++-v3/testsuite/20_util/optional/monadic/version.cc
deleted file mode 100644
index 90b2a90a5df..00000000000
--- a/libstdc++-v3/testsuite/20_util/optional/monadic/version.cc
+++ /dev/null
@@ -1,10 +0,0 @@
-// { dg-options "-std=gnu++23" }
-// { dg-do preprocess { target c++23 } }
-
-#include <version>
-
-#ifndef __cpp_lib_monadic_optional
-# error "Feature test macro for monadic optional is missing in <version>"
-#elif __cpp_lib_monadic_optional < 202110L
-# error "Feature test macro for monadic optional has wrong value in <version>"
-#endif
diff --git a/libstdc++-v3/testsuite/20_util/optional/requirements.cc b/libstdc++-v3/testsuite/20_util/optional/requirements.cc
index d6a81529c74..a56680a6fb1 100644
--- a/libstdc++-v3/testsuite/20_util/optional/requirements.cc
+++ b/libstdc++-v3/testsuite/20_util/optional/requirements.cc
@@ -23,8 +23,10 @@
# error "Feature test macro for optional is missing in <optional>"
#elif __cpp_lib_optional < 201606L
# error "Feature test macro for optional has wrong value in <optional>"
-#elif __cplusplus >= 202002L && __cpp_lib_optional < 202106L
+#elif __cplusplus == 202002L && __cpp_lib_optional != 202106L
# error "Feature test macro for optional has wrong value for C++20 in <optional>"
+#elif __cplusplus > 202002L && __cpp_lib_optional != 202110L
+# error "Feature test macro for optional has wrong value for C++23 in <version>"
#endif
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/20_util/optional/version.cc b/libstdc++-v3/testsuite/20_util/optional/version.cc
index c18ecb8d48d..2fd52f7c194 100644
--- a/libstdc++-v3/testsuite/20_util/optional/version.cc
+++ b/libstdc++-v3/testsuite/20_util/optional/version.cc
@@ -6,6 +6,8 @@
# error "Feature test macro for optional is missing in <version>"
#elif __cplusplus == 201703L && __cpp_lib_optional != 201606L
# error "Feature test macro for optional has wrong value for C++17 in <version>"
-#elif __cplusplus >= 202002L && __cpp_lib_optional < 202106L
+#elif __cplusplus == 202002L && __cpp_lib_optional != 202106L
# error "Feature test macro for optional has wrong value for C++20 in <version>"
+#elif __cplusplus > 202002L && __cpp_lib_optional != 202110L
+# error "Feature test macro for optional has wrong value for C++23 in <version>"
#endif
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc
index 1f97224bf6a..a1902745a3e 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc
@@ -18,6 +18,8 @@
// Check constexpr constructor.
constinit std::atomic<std::shared_ptr<int>> a;
+// LWG 3661. constinit atomic<shared_ptr<T>> a(nullptr); should work
+constinit std::atomic<std::shared_ptr<int>> a2 = nullptr;
void
test_is_lock_free()
diff --git a/libstdc++-v3/testsuite/20_util/stacktrace/entry.cc b/libstdc++-v3/testsuite/20_util/stacktrace/entry.cc
deleted file mode 100644
index 0bbcabd8fae..00000000000
--- a/libstdc++-v3/testsuite/20_util/stacktrace/entry.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// { dg-options "-std=gnu++23 -lstdc++_libbacktrace" }
-// { dg-do run { target c++23 } }
-// { dg-require-effective-target stacktrace }
-
-#include <stacktrace>
-#include "testsuite_hooks.h"
-
-static_assert( std::regular<std::stacktrace_entry> );
-static_assert( std::three_way_comparable<std::stacktrace_entry> );
-
-constexpr bool
-test_constexpr()
-{
- std::stacktrace_entry empty;
- VERIFY( !empty );
- VERIFY( empty == empty );
- VERIFY( std::is_eq(empty <=> empty) );
-
- std::stacktrace_entry::native_handle_type native = empty.native_handle();
- VERIFY( empty.native_handle() == native );
-
- return true;
-}
-static_assert( test_constexpr() );
-
-void
-test_members()
-{
- std::stacktrace_entry empty;
- VERIFY( empty.description().size() == 0 );
- VERIFY( empty.source_file().size() == 0 );
- VERIFY( empty.source_line() == 0 );
-
- std::stacktrace_entry e1 = std::stacktrace::current().at(0);
- std::stacktrace_entry e2 = std::stacktrace::current().at(0);
- VERIFY( e1 != e2 );
- VERIFY( e1.description() == e2.description() );
- VERIFY( e1.source_file() == e2.source_file() );
- VERIFY( e1.source_line() != e2.source_line() );
-
- std::stacktrace_entry e3 = []{
- return std::stacktrace::current().at(0);
- }();
- VERIFY( e1 != e3 );
- VERIFY( e1.description() != e3.description() );
- VERIFY( e1.source_file() == e3.source_file() );
- VERIFY( e1.source_line() != e3.source_line() );
-}
-
-int main()
-{
- test_constexpr();
-}
diff --git a/libstdc++-v3/testsuite/20_util/stacktrace/synopsis.cc b/libstdc++-v3/testsuite/20_util/stacktrace/synopsis.cc
deleted file mode 100644
index 72582fa53c6..00000000000
--- a/libstdc++-v3/testsuite/20_util/stacktrace/synopsis.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++23" }
-// { dg-do compile { target c++23 } }
-// { dg-require-effective-target stacktrace }
-
-#include <stacktrace>
-
-#ifndef __cpp_lib_stacktrace
-# error "Feature-test macro for stacktrace missing in <stacktrace>"
-#elif __cpp_lib_stacktrace < 202011L
-# error "Feature-test macro for stacktrace has wrong value in <stacktrace>"
-#endif
-
-namespace std
-{
- class stacktrace_entry;
-
- template<class Allocator>
- class basic_stacktrace;
-
- using stacktrace = basic_stacktrace<allocator<stacktrace_entry>>;
-
- template<class Allocator>
- void swap(basic_stacktrace<Allocator>& a, basic_stacktrace<Allocator>& b)
- noexcept(noexcept(a.swap(b)));
-
- string to_string(const stacktrace_entry& f);
-
- template<class Allocator>
- string to_string(const basic_stacktrace<Allocator>& st);
-
- template<class charT, class traits>
- basic_ostream<charT, traits>&
- operator<<(basic_ostream<charT, traits>& os, const stacktrace_entry& f);
-
- template<class charT, class traits, class Allocator>
- basic_ostream<charT, traits>&
- operator<<(basic_ostream<charT, traits>& os, const basic_stacktrace<Allocator>& st);
-
- namespace pmr {
- using stacktrace = basic_stacktrace<polymorphic_allocator<stacktrace_entry>>;
- }
-
- template<class T> struct hash;
- template<> struct hash<stacktrace_entry>;
- template<class Allocator> struct hash<basic_stacktrace<Allocator>>;
-}
diff --git a/libstdc++-v3/testsuite/20_util/stacktrace/version.cc b/libstdc++-v3/testsuite/20_util/stacktrace/version.cc
deleted file mode 100644
index ed466be5a36..00000000000
--- a/libstdc++-v3/testsuite/20_util/stacktrace/version.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// { dg-options "-std=gnu++23" }
-// { dg-do preprocess { target c++23 } }
-// { dg-require-effective-target stacktrace }
-
-#include <version>
-
-#ifndef __cpp_lib_stacktrace
-# error "Feature-test macro for stacktrace missing in <version>"
-#elif __cpp_lib_stacktrace < 202011L
-# error "Feature-test macro for stacktrace has wrong value in <version>"
-#endif
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/constexpr.cc
new file mode 100644
index 00000000000..fb4acbda2d5
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/constexpr.cc
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+constexpr bool
+test_move()
+{
+ std::unique_ptr<int> p1(new int(2));
+ std::unique_ptr<int> p2;
+ p2 = std::move(p1);
+ VERIFY( *p2 == 2 );
+ std::unique_ptr<int[]> a1(new int[]{0, 1, 2});
+ std::unique_ptr<int[]> a2;
+ a2 = std::move(a1);
+ VERIFY( a2[2] == 2 );
+
+ return true;
+}
+static_assert( test_move() );
+
+constexpr bool
+test_convert()
+{
+ std::unique_ptr<int> p1(new int(2));
+ std::unique_ptr<const int> p2;
+ p2 = std::move(p1);
+ VERIFY( *p2 == 2 );
+ std::unique_ptr<int[]> a1(new int[]{0, 1, 2});
+ std::unique_ptr<const int[]> a2;
+ a2 = std::move(a1);
+ VERIFY( a2[2] == 2 );
+
+ return true;
+}
+static_assert( test_convert() );
+
+constexpr bool
+test_null()
+{
+ std::unique_ptr<int> p(new int(2));
+ p = nullptr;
+ VERIFY( !p );
+ p = nullptr;
+ return true;
+}
+static_assert( test_null() );
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/constexpr.cc
new file mode 100644
index 00000000000..83e4f0826a8
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/constexpr.cc
@@ -0,0 +1,73 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+constexpr bool
+test_eq()
+{
+ std::unique_ptr<int> p1, p2;
+ VERIFY( p1 == p2 );
+ p1.reset(new int(1));
+ VERIFY( p1 == p1 );
+ VERIFY( p1 != p2 );
+ struct null_deleter { constexpr void operator()(const void*) const { } };
+ std::unique_ptr<const int[], null_deleter> p3(p1.get());
+ VERIFY( p3 == p3 );
+ VERIFY( p1 == p3 );
+ VERIFY( p3 != p2 );
+
+ return true;
+}
+static_assert( test_eq() );
+
+constexpr bool
+test_rel()
+{
+ std::unique_ptr<int> p1, p2;
+ VERIFY( !(p1 < p2) );
+ VERIFY( !(p1 > p2) );
+ VERIFY( p1 <= p2 );
+ VERIFY( p1 >= p2 );
+ p1.reset(new int(1));
+ VERIFY( p1 <= p1 );
+ VERIFY( p1 >= p1 );
+ VERIFY( p1 > p2 );
+ VERIFY( p2 < p1 );
+ VERIFY( p2 <= p1 );
+ VERIFY( p1 >= p2 );
+ struct null_deleter { constexpr void operator()(const void*) const { } };
+ std::unique_ptr<const int[], null_deleter> p3(p1.get());
+ VERIFY( p3 <= p3 );
+ VERIFY( p3 >= p3 );
+ VERIFY( p1 <= p3 );
+ VERIFY( p3 > p2 );
+ VERIFY( p3 >= p2 );
+ VERIFY( p2 < p3 );
+ VERIFY( p2 <= p3 );
+
+ return true;
+}
+static_assert( test_rel() );
+
+constexpr bool
+test_3way()
+{
+ std::unique_ptr<int> p1, p2;
+ VERIFY( (p1 <=> p1) == 0 );
+ VERIFY( (p1 <=> p2) == 0 );
+ p1.reset(new int(1));
+ VERIFY( (p1 <=> p1) == 0 );
+ VERIFY( (p1 <=> p2) > 0 );
+ VERIFY( (p2 <=> p1) < 0 );
+ struct null_deleter { constexpr void operator()(const void*) const { } };
+ std::unique_ptr<const int[], null_deleter> p3(p1.get());
+ VERIFY( (p3 <=> p3) == 0 );
+ VERIFY( (p1 <=> p3) == 0 );
+ VERIFY( (p3 <=> p2) > 0 );
+ VERIFY( (p2 <=> p3) < 0 );
+
+ return true;
+}
+static_assert( test_3way() );
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc
new file mode 100644
index 00000000000..243d80aaba5
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc
@@ -0,0 +1,85 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <memory>
+
+#ifndef __cpp_lib_constexpr_memory
+# error "Feature test macro for constexpr unique_ptr is missing in <memory>"
+#elif __cpp_lib_constexpr_memory < 202202L
+# error "Feature test macro for constexpr unique_ptr has wrong value in <memory>"
+#endif
+
+#include <testsuite_hooks.h>
+
+constexpr bool
+test_default()
+{
+ std::unique_ptr<int> p;
+ std::unique_ptr<int> np(nullptr);
+ VERIFY( p == np );
+
+ std::unique_ptr<int[]> a;
+ std::unique_ptr<int[]> na(nullptr);
+ VERIFY( a == na );
+
+ return true;
+}
+static_assert( test_default() );
+
+constexpr bool
+test_ptr()
+{
+ std::unique_ptr<int> p(new int(2));
+ VERIFY( *p == 2 );
+ std::unique_ptr<int[]> a(new int[]{0, 1, 2});
+ VERIFY( a[2] == 2 );
+
+ return true;
+}
+static_assert( test_ptr() );
+
+constexpr bool
+test_del()
+{
+ const std::default_delete<int> pd;
+ std::unique_ptr<int> p1(new int(1), pd);
+ VERIFY( *p1 == 1 );
+ std::unique_ptr<int> p2(new int(2), std::default_delete<int>{});
+ VERIFY( *p2 == 2 );
+ const std::default_delete<int[]> ad;
+ std::unique_ptr<int[]> a1(new int[]{3, 4}, ad);
+ VERIFY( a1[0] == 3 );
+ std::unique_ptr<int[]> a2(new int[]{5, 6}, std::default_delete<int[]>{});
+ VERIFY( a2[1] == 6 );
+
+ return true;
+}
+static_assert( test_del() );
+
+constexpr bool
+test_move()
+{
+ std::unique_ptr<int> p1(new int(2));
+ std::unique_ptr<int> p2 = std::move(p1);
+ VERIFY( *p2 == 2 );
+ std::unique_ptr<int[]> a1(new int[]{0, 1, 2});
+ std::unique_ptr<int[]> a2 = std::move(a1);
+ VERIFY( a2[2] == 2 );
+
+ return true;
+}
+static_assert( test_move() );
+
+constexpr bool
+test_convert()
+{
+ std::unique_ptr<int> p1(new int(2));
+ std::unique_ptr<const int> p2 = std::move(p1);
+ VERIFY( *p2 == 2 );
+ std::unique_ptr<int[]> a1(new int[]{0, 1, 2});
+ std::unique_ptr<const int[]> a2 = std::move(a1);
+ VERIFY( a2[2] == 2 );
+
+ return true;
+}
+static_assert( test_convert() );
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/creation/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/creation/constexpr.cc
new file mode 100644
index 00000000000..90d11198578
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/creation/constexpr.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+constexpr bool
+test_creation_single()
+{
+ std::unique_ptr<int> p = std::make_unique<int>(1);
+ VERIFY( *p == 1 );
+ p = std::make_unique_for_overwrite<int>();
+ *p = 2;
+ VERIFY( *p == 2 );
+
+ return true;
+}
+static_assert( test_creation_single() );
+
+constexpr bool
+test_creation_array()
+{
+ std::unique_ptr<int[]> a = std::make_unique<int[]>(2);
+ VERIFY( a[0] == 0 );
+ VERIFY( a[1] == 0 );
+ a = std::make_unique_for_overwrite<int[]>(2);
+ a[0] = 1;
+ a[1] = 2;
+ VERIFY( a[0] == 1 );
+ VERIFY( a[1] == 2 );
+
+ return true;
+}
+static_assert( test_creation_array() );
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/constexpr.cc
new file mode 100644
index 00000000000..81908fdc081
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/constexpr.cc
@@ -0,0 +1,68 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+constexpr bool
+test_release()
+{
+ std::unique_ptr<int> p1;
+ int* r = p1.release();
+ VERIFY( !r );
+ VERIFY( !p1 );
+
+ std::unique_ptr<int> p2(new int(2));
+ r = p2.release();
+ VERIFY( r );
+ VERIFY( !p2 );
+ delete r;
+
+ std::unique_ptr<int[]> a1;
+ r = a1.release();
+ VERIFY( !r );
+ VERIFY( !a1 );
+
+ std::unique_ptr<int[]> a2(new int[2]{});
+ r = a2.release();
+ VERIFY( r );
+ VERIFY( !a2 );
+ delete[] r;
+
+ return true;
+}
+static_assert( test_release() );
+
+constexpr bool
+test_reset()
+{
+ std::unique_ptr<int> p1;
+ p1.reset();
+ VERIFY( !p1 );
+ p1.reset(nullptr);
+ VERIFY( !p1 );
+ p1.reset(new int(2));
+ VERIFY( *p1 == 2 );
+ p1.reset(new int(3));
+ VERIFY( *p1 == 3 );
+ p1.reset(nullptr);
+ VERIFY( !p1 );
+
+ std::unique_ptr<int[]> a1;
+ a1.reset();
+ VERIFY( !a1 );
+ a1.reset(nullptr);
+ VERIFY( !a1 );
+ a1.reset(new int[]{2,3});
+ VERIFY( a1[0] == 2 );
+ a1.reset(new int[]{4,5,6});
+ VERIFY( a1[1] == 5 );
+ a1.reset(nullptr);
+ VERIFY( !a1 );
+
+ std::unique_ptr<const int[]> a2;
+ a2.reset(new int[2]{});
+
+ return true;
+}
+static_assert( test_reset() );
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/constexpr.cc
new file mode 100644
index 00000000000..91a0165d212
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/constexpr.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+constexpr bool
+test_swap_single()
+{
+ std::unique_ptr<int> p1;
+ swap(p1, p1);
+ VERIFY( !p1 );
+ std::unique_ptr<int> p2;
+ swap(p1, p2);
+ VERIFY( !p1 && !p2 );
+ std::unique_ptr<int> p3(new int(3));
+ swap(p3, p3);
+ VERIFY( *p3 == 3 );
+ swap(p1, p3);
+ VERIFY( *p1 == 3 );
+ std::unique_ptr<int> p4(new int(4));
+ swap(p4, p1);
+ VERIFY( *p4 == 3 );
+ VERIFY( *p1 == 4 );
+
+ return true;
+}
+static_assert( test_swap_single() );
+
+constexpr bool
+test_swap_array()
+{
+ std::unique_ptr<int[]> a1;
+ std::unique_ptr<int[]> a2;
+ swap(a1, a2);
+ VERIFY( !a1 && !a2 );
+ std::unique_ptr<int[]> a3(new int[]{3});
+ swap(a1, a3);
+ VERIFY( a1[0] == 3 );
+ std::unique_ptr<int[]> a4(new int[]{4, 5});
+ swap(a1, a4);
+ VERIFY( a1[1] == 5 );
+
+ return true;
+}
+static_assert( test_swap_array() );