[libcxx-commits] [libcxx] [libc++] P3247R2: Deprecate `is_trivial(_v)` (PR #130573)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 10 03:25:32 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

<details>
<summary>Changes</summary>

Requirements on character-like types are updated unconditionally, because `basic_string` does requires the default-constructibility. It might be possible to make `basic_string_view` support classes with non-public trivial default constructor, but this doesn't seem sensible.

`is_trivial(_v)` are kept in test files when `is_pod(_v)` are kept, or when being tested theirselves.

Drive-by:
- Rewrites `libcxx/test/std/language.support/support.types/byte.pass.cpp` with C++17 features and removes some questionable comments in it.

Fixes #<!-- -->118387.

---

Patch is 45.36 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/130573.diff


26 Files Affected:

- (modified) libcxx/docs/ReleaseNotes/21.rst (+3) 
- (modified) libcxx/docs/Status/Cxx2cPapers.csv (+1-1) 
- (modified) libcxx/include/__iterator/aliasing_iterator.h (+4-2) 
- (modified) libcxx/include/__type_traits/is_char_like_type.h (+4-2) 
- (modified) libcxx/include/__type_traits/is_trivial.h (+3-3) 
- (modified) libcxx/include/string (+5-2) 
- (modified) libcxx/include/string_view (+6-2) 
- (modified) libcxx/include/type_traits (+2-2) 
- (modified) libcxx/test/libcxx/memory/allocator_void.trivial.compile.pass.cpp (+2-2) 
- (modified) libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/libcxx.control_block_layout.pass.cpp (+3-1) 
- (modified) libcxx/test/libcxx/utilities/utility/private_constructor_tag.compile.pass.cpp (+2-1) 
- (modified) libcxx/test/std/depr/depr.c.headers/stddef_h.compile.pass.cpp (+6-4) 
- (modified) libcxx/test/std/language.support/support.types/byte.pass.cpp (+24-16) 
- (modified) libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp (+6-2) 
- (modified) libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp (+2-1) 
- (modified) libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp (+2-1) 
- (modified) libcxx/test/std/ranges/range.req/range.view/view_base.compile.pass.cpp (+2-1) 
- (modified) libcxx/test/std/strings/basic.string/char.bad.verify.cpp (+22-6) 
- (modified) libcxx/test/std/strings/string.view/char.bad.verify.cpp (+22-6) 
- (modified) libcxx/test/std/time/time.zone/time.zone.zonedtraits/types.compile.pass.cpp (+8-4) 
- (modified) libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp (+109-17) 
- (modified) libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp (+18-9) 
- (added) libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.deprecated.verify.cpp (+18) 
- (modified) libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp (+2) 
- (modified) libcxx/test/std/utilities/tuple/tuple.general/ignore.pass.cpp (+2-1) 
- (modified) libcxx/test/support/nasty_string.h (+2-1) 


``````````diff
diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index 633d114693c82..0bbbcf9e433e3 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -42,6 +42,7 @@ Implemented Papers
 - P0767R1: Deprecate POD (`Github <https://github.com/llvm/llvm-project/issues/104013>`__)
 - P1361R2: Integration of chrono with text formatting (`Github <https://github.com/llvm/llvm-project/issues/100014>`__)
 - P2255R2: A type trait to detect reference binding to temporary (implemented the type traits only) (`Github <https://github.com/llvm/llvm-project/issues/105180>`__)
+- P3247R2: Deprecate the notion of trivial types (`Github <https://github.com/llvm/llvm-project/issues/118387>`__)
 
 Improvements and New Features
 -----------------------------
@@ -62,6 +63,8 @@ Deprecations and Removals
 
 - ``std::is_pod`` and ``std::is_pod_v`` are deprecated in C++20 and later.
 
+- ``std::is_trivial`` and ``std::is_trivial_v`` are deprecated in C++26 and later.
+
 Upcoming Deprecations and Removals
 ----------------------------------
 
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index 1436db6cf2b45..68f9d8e88d238 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -94,7 +94,7 @@
 "`P1928R15 <https://wg21.link/P1928R15>`__","``std::simd`` — merge data-parallel types from the Parallelism TS 2","2024-11 (Wrocław)","","",""
 "`P3325R5 <https://wg21.link/P3325R5>`__","A Utility for Creating Execution Environments","2024-11 (Wrocław)","","",""
 "`P3068R6 <https://wg21.link/P3068R6>`__","Allowing exception throwing in constant-evaluation","2024-11 (Wrocław)","","",""
-"`P3247R2 <https://wg21.link/P3247R2>`__","Deprecate the notion of trivial types","2024-11 (Wrocław)","","",""
+"`P3247R2 <https://wg21.link/P3247R2>`__","Deprecate the notion of trivial types","2024-11 (Wrocław)","|Complete|","21",""
 "","","","","",""
 "`P3074R7 <https://wg21.link/P3074R7>`__","trivial unions (was ``std::uninitialized``)","2025-02 (Hagenberg)","","",""
 "`P1494R5 <https://wg21.link/P1494R5>`__","Partial program correctness","2025-02 (Hagenberg)","","",""
diff --git a/libcxx/include/__iterator/aliasing_iterator.h b/libcxx/include/__iterator/aliasing_iterator.h
index 98b212cb39296..a6506b8e25786 100644
--- a/libcxx/include/__iterator/aliasing_iterator.h
+++ b/libcxx/include/__iterator/aliasing_iterator.h
@@ -14,7 +14,8 @@
 #include <__iterator/iterator_traits.h>
 #include <__memory/addressof.h>
 #include <__memory/pointer_traits.h>
-#include <__type_traits/is_trivial.h>
+#include <__type_traits/is_trivially_constructible.h>
+#include <__type_traits/is_trivially_copyable.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -45,7 +46,8 @@ struct __aliasing_iterator_wrapper {
     using reference         = value_type&;
     using pointer           = value_type*;
 
-    static_assert(is_trivial<value_type>::value);
+    static_assert(is_trivially_default_constructible<value_type>::value);
+    static_assert(is_trivially_constructible<value_type>::value);
     static_assert(sizeof(__base_value_type) == sizeof(value_type));
 
     _LIBCPP_HIDE_FROM_ABI __iterator() = default;
diff --git a/libcxx/include/__type_traits/is_char_like_type.h b/libcxx/include/__type_traits/is_char_like_type.h
index 913c0821c8c68..ca440b52fcd45 100644
--- a/libcxx/include/__type_traits/is_char_like_type.h
+++ b/libcxx/include/__type_traits/is_char_like_type.h
@@ -12,7 +12,8 @@
 #include <__config>
 #include <__type_traits/conjunction.h>
 #include <__type_traits/is_standard_layout.h>
-#include <__type_traits/is_trivial.h>
+#include <__type_traits/is_trivially_constructible.h>
+#include <__type_traits/is_trivially_copyable.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -21,7 +22,8 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _CharT>
-using _IsCharLikeType _LIBCPP_NODEBUG = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
+using _IsCharLikeType _LIBCPP_NODEBUG =
+    _And<is_standard_layout<_CharT>, is_trivially_default_constructible<_CharT>, is_trivially_copyable<_CharT> >;
 
 _LIBCPP_END_NAMESPACE_STD
 
diff --git a/libcxx/include/__type_traits/is_trivial.h b/libcxx/include/__type_traits/is_trivial.h
index a4ca2d6b26d0e..67a68dcb138f0 100644
--- a/libcxx/include/__type_traits/is_trivial.h
+++ b/libcxx/include/__type_traits/is_trivial.h
@@ -19,12 +19,12 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> {
-};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_NO_SPECIALIZATIONS is_trivial
+    : public integral_constant<bool, __is_trivial(_Tp)> {};
 
 #if _LIBCPP_STD_VER >= 17
 template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp);
+_LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp);
 #endif
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/string b/libcxx/include/string
index ea9ba24084a3b..6c562e24daca9 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -632,7 +632,8 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
 #  include <__type_traits/is_nothrow_constructible.h>
 #  include <__type_traits/is_same.h>
 #  include <__type_traits/is_standard_layout.h>
-#  include <__type_traits/is_trivial.h>
+#  include <__type_traits/is_trivially_constructible.h>
+#  include <__type_traits/is_trivially_copyable.h>
 #  include <__type_traits/is_trivially_relocatable.h>
 #  include <__type_traits/remove_cvref.h>
 #  include <__type_traits/void_t.h>
@@ -788,7 +789,9 @@ public:
 
   static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");
   static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");
-  static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial");
+  static_assert(is_trivial_default_constructible<value_type>::value,
+                "Character type of basic_string must be trivially default constructible");
+  static_assert(is_trivially_copyable<value_type>::value, "Character type of basic_string must be trivially copyable");
   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
                 "traits_type::char_type must be the same type as CharT");
   static_assert(is_same<typename allocator_type::value_type, value_type>::value,
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index c640ae4e79865..5054b14efd2d5 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -235,7 +235,8 @@ namespace std {
 #  include <__type_traits/is_convertible.h>
 #  include <__type_traits/is_same.h>
 #  include <__type_traits/is_standard_layout.h>
-#  include <__type_traits/is_trivial.h>
+#  include <__type_traits/is_trivially_constructible.h>
+#  include <__type_traits/is_trivially_copyable.h>
 #  include <__type_traits/remove_cvref.h>
 #  include <__type_traits/remove_reference.h>
 #  include <__type_traits/type_identity.h>
@@ -302,7 +303,10 @@ public:
 
   static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array");
   static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");
-  static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial");
+  static_assert(is_trivially_default_constructible<value_type>::value,
+                "Character type of basic_string_view must be trivially default constructible");
+  static_assert(is_trivially_copyable<value_type>::value,
+                "Character type of basic_string_view must be trivially copyable");
   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
                 "traits_type::char_type must be the same type as CharT");
 
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index a03a60917cd54..b63f61cfefe8e 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -93,7 +93,7 @@ namespace std
     template <class T> struct is_unbounded_array;               // since C++20
 
     // Member introspection:
-    template <class T> struct is_trivial;
+    template <class T> struct is_trivial;                       // deprecated in C++26
     template <class T> struct is_pod;                           // deprecated in C++20
     template <class T> struct is_trivially_copyable;
     template <class T> struct is_standard_layout;
@@ -323,7 +323,7 @@ namespace std
       template <class T> inline constexpr bool is_volatile_v
         = is_volatile<T>::value;                                // since C++17
       template <class T> inline constexpr bool is_trivial_v
-        = is_trivial<T>::value;                                 // since C++17
+        = is_trivial<T>::value;                                 // since C++17; deprecated in C++26
       template <class T> inline constexpr bool is_trivially_copyable_v
         = is_trivially_copyable<T>::value;                      // since C++17
       template <class T> inline constexpr bool is_standard_layout_v
diff --git a/libcxx/test/libcxx/memory/allocator_void.trivial.compile.pass.cpp b/libcxx/test/libcxx/memory/allocator_void.trivial.compile.pass.cpp
index 69a4b8943caa6..b7dfc190e8e91 100644
--- a/libcxx/test/libcxx/memory/allocator_void.trivial.compile.pass.cpp
+++ b/libcxx/test/libcxx/memory/allocator_void.trivial.compile.pass.cpp
@@ -20,7 +20,7 @@ typedef std::allocator<void> A1;
 struct A2 : std::allocator<void> { };
 
 static_assert(std::is_trivially_default_constructible<A1>::value, "");
-static_assert(std::is_trivial<A1>::value, "");
+static_assert(std::is_trivially_copyable<A1>::value, "");
 
 static_assert(std::is_trivially_default_constructible<A2>::value, "");
-static_assert(std::is_trivial<A2>::value, "");
+static_assert(std::is_trivially_copyable<A2>::value, "");
diff --git a/libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/libcxx.control_block_layout.pass.cpp b/libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/libcxx.control_block_layout.pass.cpp
index 7488f518c8bae..744938a78dbe1 100644
--- a/libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/libcxx.control_block_layout.pass.cpp
+++ b/libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/libcxx.control_block_layout.pass.cpp
@@ -123,7 +123,9 @@ void test() {
 
   // Make sure both types have the same triviality (that has ABI impact since
   // it determined how objects are passed). Both should be non-trivial.
-  static_assert(std::is_trivial<New>::value == std::is_trivial<Old>::value, "");
+  static_assert((std::is_trivially_copyable<New>::value && std::is_trivially_default_constructible<New>::value) ==
+                    (std::is_trivially_copyable<Old>::value && std::is_trivially_default_constructible<Old>::value),
+                "");
 }
 
 // Object types to store in the control block
diff --git a/libcxx/test/libcxx/utilities/utility/private_constructor_tag.compile.pass.cpp b/libcxx/test/libcxx/utilities/utility/private_constructor_tag.compile.pass.cpp
index bae0824109071..1644819a02f7f 100644
--- a/libcxx/test/libcxx/utilities/utility/private_constructor_tag.compile.pass.cpp
+++ b/libcxx/test/libcxx/utilities/utility/private_constructor_tag.compile.pass.cpp
@@ -18,4 +18,5 @@
 #include <__utility/private_constructor_tag.h>
 #include <type_traits>
 
-static_assert(std::is_trivial<std::__private_constructor_tag>::value, "");
+static_assert(std::is_trivially_copyable<std::__private_constructor_tag>::value, "");
+static_assert(std::is_trivially_default_constructible<std::__private_constructor_tag>::value, "");
diff --git a/libcxx/test/std/depr/depr.c.headers/stddef_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stddef_h.compile.pass.cpp
index fed867f460f26..c1632dd9f180d 100644
--- a/libcxx/test/std/depr/depr.c.headers/stddef_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/stddef_h.compile.pass.cpp
@@ -42,11 +42,13 @@ static_assert(std::is_integral<ptrdiff_t>::value, "");
 static_assert((std::is_same<decltype(nullptr), nullptr_t>::value), "");
 static_assert(sizeof(nullptr_t) == sizeof(void*), "");
 #if TEST_STD_VER >= 11
-#  if TEST_STD_VER >= 20
-// P0767
-static_assert(std::is_trivial<max_align_t>::value, "");
+static_assert(std::is_trivially_copyable<max_align_t>::value, "");
+static_assert(std::is_trivially_default_constructible<max_align_t>::value, "");
 static_assert(std::is_standard_layout<max_align_t>::value, "");
-#  else
+#  if TEST_STD_VER < 26 // P3247R2
+static_assert(std::is_trivial<max_align_t>::value, "");
+#  endif
+#  if TEST_STD_VER < 20 // P0767R1
 static_assert(std::is_pod<max_align_t>::value, "");
 #  endif
 static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<long long>::value, "");
diff --git a/libcxx/test/std/language.support/support.types/byte.pass.cpp b/libcxx/test/std/language.support/support.types/byte.pass.cpp
index e79af0dec6550..aa37faa5811da 100644
--- a/libcxx/test/std/language.support/support.types/byte.pass.cpp
+++ b/libcxx/test/std/language.support/support.types/byte.pass.cpp
@@ -10,26 +10,34 @@
 #include <type_traits>
 #include "test_macros.h"
 
-// XFAIL: c++03, c++11, c++14
+// REQUIRES: std-at-least-c++17
 
 // std::byte is not an integer type, nor a character type.
-// It is a distinct type for accessing the bits that ultimately make up object storage.
+// It is a distinct scoped enumeration type for accessing the bits that ultimately make up object storage.
 
-#if TEST_STD_VER > 17
-static_assert( std::is_trivial<std::byte>::value, "" );   // P0767
-#else
-static_assert( std::is_pod<std::byte>::value, "" );
+static_assert(std::is_enum_v<std::byte>);
+#if TEST_STD_VER >= 23
+static_assert(std::is_scoped_enum_v<std::byte>);
 #endif
-static_assert(!std::is_arithmetic<std::byte>::value, "" );
-static_assert(!std::is_integral<std::byte>::value, "" );
+static_assert(std::is_same_v<std::underlying_type_t<std::byte>, unsigned char>);
+static_assert(!std::is_convertible_v<std::byte, unsigned char>);
+static_assert(sizeof(std::byte) == 1);
 
-static_assert(!std::is_same<std::byte,          char>::value, "" );
-static_assert(!std::is_same<std::byte,   signed char>::value, "" );
-static_assert(!std::is_same<std::byte, unsigned char>::value, "" );
+static_assert(std::is_trivially_copyable_v<std::byte>);
+static_assert(std::is_trivially_default_constructible_v<std::byte>);
+#if TEST_STD_VER < 26 // P3247R2
+static_assert(std::is_trivial_v<std::byte>);
+#endif
+#if TEST_STD_VER < 20 // P0767R1
+static_assert(std::is_pod_v<std::byte>);
+#endif
+static_assert(std::is_standard_layout_v<std::byte>);
+
+static_assert(!std::is_arithmetic_v<std::byte>);
+static_assert(!std::is_integral_v<std::byte>);
 
-// The standard doesn't outright say this, but it's pretty clear that it has to be true.
-static_assert(sizeof(std::byte) == 1, "" );
+static_assert(!std::is_same_v<std::byte, char>);
+static_assert(!std::is_same_v<std::byte, signed char>);
+static_assert(!std::is_same_v<std::byte, unsigned char>);
 
-int main(int, char**) {
-  return 0;
-}
+int main(int, char**) { return 0; }
diff --git a/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp b/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp
index 5e335841c2a3c..ec6e82ff86e0e 100644
--- a/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp
@@ -16,9 +16,13 @@
 
 #include "test_macros.h"
 
-static_assert(std::is_trivial<std::max_align_t>::value, "");
+static_assert(std::is_trivially_copyable<std::max_align_t>::value, "");
+static_assert(std::is_trivially_default_constructible<std::max_align_t>::value, "");
 static_assert(std::is_standard_layout<std::max_align_t>::value, "");
-#if TEST_STD_VER <= 17
+#if TEST_STD_VER < 26 // P3247R2
+static_assert(std::is_trivial<std::max_align_t>::value, "");
+#endif
+#if TEST_STD_VER < 20 // P0767R1
 static_assert(std::is_pod<std::max_align_t>::value, "");
 #endif
 static_assert(alignof(std::max_align_t) >= alignof(long long), "");
diff --git a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
index 060f179fe1683..3f4317a724add 100644
--- a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
+++ b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
@@ -23,7 +23,8 @@ template <class CPO, class... Args>
 constexpr bool test(CPO& o, Args&&...) {
   static_assert(std::is_const_v<CPO>);
   static_assert(std::is_class_v<CPO>);
-  static_assert(std::is_trivial_v<CPO>);
+  static_assert(std::is_trivially_copyable_v<CPO>);
+  static_assert(std::is_trivially_default_constructible_v<CPO>);
 
   auto p = o;
   using T = decltype(p);
diff --git a/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp b/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
index 5a2ee189641c7..402bc1c9351aa 100644
--- a/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
+++ b/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
@@ -36,7 +36,8 @@ template <class CPO, class... Args>
 constexpr bool test(CPO& o, Args&&...) {
   static_assert(std::is_const_v<CPO>);
   static_assert(std::is_class_v<CPO>);
-  static_assert(std::is_trivial_v<CPO>);
+  static_assert(std::is_trivially_copyable_v<CPO>);
+  static_assert(std::is_trivially_default_constructible_v<CPO>);
 
   auto p = o;
   using T = decltype(p);
diff --git a/libcxx/test/std/ranges/range.req/range.view/view_base.compile.pass.cpp b/libcxx/test/std/ranges/range.req/range.view/view_base.compile.pass.cpp
index ca9525d585b45..84293e3ed0cbf 100644
--- a/libcxx/test/std/ranges/range.req/range.view/view_base.compile.pass.cpp
+++ b/libcxx/test/std/ranges/range.req/range.view/view_base.compile.pass.cpp
@@ -16,7 +16,8 @@
 #include <type_traits>
 
 static_assert(std::is_empty_v<std::ranges::view_base>);
-static_assert(std::is_trivial_v<std::ranges::view_base>);
+static_assert(std::is_trivially_copyable_v<std::ranges::view_base>);
+static_assert(std::is_trivially_default_constructible_v<std::ranges::view_base>);
 
 // Make sure we can inherit from it, as it's intended (that wouldn't be the
 // case if e.g. it was marked as final).
diff --git a/libcxx/test/std/strings/basic.string/char.bad.verify.cpp b/libcxx/test/std/strings/basic.string/char.bad.verify.cpp
index 557604b415de3..8411b22e019c2 100644
--- a/libcxx/test/std/strings/basic.string/char.bad.verify.cpp
+++ b/libcxx/test/std/strings/basic.string/char.bad.verify.cpp
@@ -10,10 +10,19 @@
 //   ... manipulating sequences of any non-array trivial standard-layout types.
 
 #include <string>
+#include <type_traits>
 #include "test_traits.h"
 
-struct NotTrivial {
-  NotTrivial() : value(3) {}
+struct NotTriviallyCopyable {
+  int value;
+  NotTriviallyCopyable& operator=(const NotTriviallyCopyable& other) {
+    value = other.value;
+    return *this;
+  }
+};
+
+struct NotTriviallyDefaultConstructible {
+  NotTriviallyDefaultConstructible() : value(3) {}
   int value;
 };
 
@@ -37,10 +46,17 @@ void f() {
   }
 
   {
-    // not trivial
-    static_assert(!std::is_trivial<NotTrivial>::value, "");
-    std::basic_string<NotTrivial, test_traits<NotTrivial> > s;
-    // expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be trivial}}
+    // not trivially copyable
+    static_assert(!std::is_trivially_copyable<NotTriviallyCopyable>::value, "");
+    std::basic_string<NotTriviallyCopyable, test_traits<NotTriviallyCopyable> > s;
+    // expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be trivially copyable}}
+  }
+
+  {
+    // not trivially default constructible
+    static_assert(!std::is_trivially_default_const...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/130573


More information about the libcxx-commits mailing list