The P3471R4 and P3697R1 proposals adding hardened preconditions also
defined feature test macros that indicate whether the hardened
preconditions are checked. For our implementation, those checks are
enabled by defining _GLIBCXX_ASSERTIONS.

To implement this, I've added all the __cpp_lib_hardened_xxx macros at
the end of bits/version.def, because the simplest way to define many of
them seems to be to make the depend on the macro for the main feature
and additionally depend on defined(_GLIBCXX_ASSERTIONS).

The hardening checks were added to each component as follows:

std::array                  r11-4854-g6db082477ad839
std::bitset                 r16-7919-g1b404c574450a4
std::deque                  r7-1526-gbd2ee798d5a5a3
std::expected               since first commit
std::forward_list           r15-5721-ge7aa614d7372b5
std::inplace_vector         since first commit
std::common_iterator        since first commit
std::counted_iterator       since first commit
std::list                   r15-5721-ge7aa614d7372b5
std::shared_ptr<T[]>        since first commit
std::optional               r8-711-g2c27a627a31034
std::ranges::view_interface since first commit
std::span                   r10-2983-gb5c433ce11a140
std::basic_stacktrace       since first commit
std::basic_string           r6-3197-g2f1e8e7c4730bb
std::basic_string_view      r11-2881-g3eefb302d2bd85
std::valarray               r6-3197-g2f1e8e7c4730bb
std::vector                 r6-3197-g2f1e8e7c4730bb

This commit does not define __cpp_lib_hardened_mdspan, that was added in
r17-1258-g19def756dec1fe earlier today.

This commit does not include the LWG 4577 changes to harden
view_interface::operator[] which will be added later (with a new value
for the __cpp_lib_hardened_view_interface macro).

libstdc++-v3/ChangeLog:

        * include/bits/version.def: Define macros for hardened
        preconditions.
        * include/bits/version.h: Regenerate.
        * include/std/array: Define "want" macro for hardened
        precondition macro.
        * include/std/bitset: Likewise.
        * include/std/deque: Likewise.
        * include/std/expected: Likewise.
        * include/std/forward_list: Likewise.
        * include/std/inplace_vector: Likewise.
        * include/std/iterator: Likewise.
        * include/std/list: Likewise.
        * include/std/memory: Likewise.
        * include/std/optional: Likewise.
        * include/std/ranges: Likewise.
        * include/std/span: Likewise.
        * include/std/stacktrace: Likewise.
        * include/std/string: Likewise.
        * include/std/string_view: Likewise.
        * include/std/valarray: Likewise.
        * include/std/vector: Likewise.
        * testsuite/23_containers/array/tuple_interface/get_neg.cc:
        Adjust dg-error line numbers.

Reviewed-by: Nathan Myers <[email protected]>
Reviewed-by: Tomasz KamiƄski <[email protected]>
---

v2: dropped mdspan macro, more detail in commit message.

Tested x86_64-linux. Pushed to trunk.

 libstdc++-v3/include/bits/version.def         | 150 ++++++++++++++-
 libstdc++-v3/include/bits/version.h           | 180 ++++++++++++++++++
 libstdc++-v3/include/std/array                |   1 +
 libstdc++-v3/include/std/bitset               |   1 +
 libstdc++-v3/include/std/deque                |   1 +
 libstdc++-v3/include/std/expected             |   1 +
 libstdc++-v3/include/std/forward_list         |   1 +
 libstdc++-v3/include/std/inplace_vector       |   1 +
 libstdc++-v3/include/std/iterator             |   2 +
 libstdc++-v3/include/std/list                 |   1 +
 libstdc++-v3/include/std/memory               |   1 +
 libstdc++-v3/include/std/optional             |   1 +
 libstdc++-v3/include/std/ranges               |   1 +
 libstdc++-v3/include/std/span                 |   1 +
 libstdc++-v3/include/std/stacktrace           |   1 +
 libstdc++-v3/include/std/string               |   1 +
 libstdc++-v3/include/std/string_view          |   1 +
 libstdc++-v3/include/std/valarray             |   1 +
 libstdc++-v3/include/std/vector               |   1 +
 .../array/tuple_interface/get_neg.cc          |   6 +-
 20 files changed, 350 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/version.def 
b/libstdc++-v3/include/bits/version.def
index df7190bec487..5dddf4cf3452 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -2448,7 +2448,107 @@ ftms = {
   name = valarray;
   values = {
     v = 202511;
-    cxxmin = 26; 
+    cxxmin = 26;
+  };
+};
+
+ftms = {
+  name = hardened_array;
+  values = {
+    v = 202502;
+    cxxmin = 11;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_basic_stacktrace;
+  values = {
+    v = 202502;
+    cxxmin = 23;
+    hosted = yes;
+    extra_cond = "defined(__glibcxx_stacktrace) && 
defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_basic_string;
+  values = {
+    v = 202502;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_basic_string_view;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_string_view) && 
defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_bitset;
+  values = {
+    v = 202502;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_common_iterator;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_ranges) && defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_counted_iterator;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_ranges) && defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_deque;
+  values = {
+    v = 202502;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_expected;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_expected) && defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_forward_list;
+  values = {
+    v = 202502;
+    cxxmin = 11;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_inplace_vector;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_inplace_vector) && 
defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_list;
+  values = {
+    v = 202502;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
   };
 };
 
@@ -2460,6 +2560,54 @@ ftms = {
   };
 };
 
+ftms = {
+  name = hardened_optional;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_optional) && defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_shared_ptr_array;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_shared_ptr_arrays) && 
defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_span;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_span) && defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_valarray;
+  values = {
+    v = 202502;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_vector;
+  values = {
+    v = 202502;
+    extra_cond = "defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
+ftms = {
+  name = hardened_view_interface;
+  values = {
+    v = 202502;
+    extra_cond = "defined(__glibcxx_ranges) && defined(_GLIBCXX_ASSERTIONS)";
+  };
+};
+
 // Standard test specifications.
 stds[97] = ">= 199711L";
 stds[03] = ">= 199711L";
diff --git a/libstdc++-v3/include/bits/version.h 
b/libstdc++-v3/include/bits/version.h
index 1a07f1153582..787315033bb8 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -2710,6 +2710,126 @@
 #endif /* !defined(__cpp_lib_valarray) */
 #undef __glibcxx_want_valarray
 
+#if !defined(__cpp_lib_hardened_array)
+# if (__cplusplus >= 201103L) && (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_array 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_array)
+#   define __cpp_lib_hardened_array 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_array) */
+#undef __glibcxx_want_hardened_array
+
+#if !defined(__cpp_lib_hardened_basic_stacktrace)
+# if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED && 
(defined(__glibcxx_stacktrace) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_basic_stacktrace 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_basic_stacktrace)
+#   define __cpp_lib_hardened_basic_stacktrace 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_basic_stacktrace) */
+#undef __glibcxx_want_hardened_basic_stacktrace
+
+#if !defined(__cpp_lib_hardened_basic_string)
+# if (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_basic_string 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_basic_string)
+#   define __cpp_lib_hardened_basic_string 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_basic_string) */
+#undef __glibcxx_want_hardened_basic_string
+
+#if !defined(__cpp_lib_hardened_basic_string_view)
+# if (defined(__glibcxx_string_view) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_basic_string_view 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_basic_string_view)
+#   define __cpp_lib_hardened_basic_string_view 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_basic_string_view) */
+#undef __glibcxx_want_hardened_basic_string_view
+
+#if !defined(__cpp_lib_hardened_bitset)
+# if (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_bitset 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_bitset)
+#   define __cpp_lib_hardened_bitset 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_bitset) */
+#undef __glibcxx_want_hardened_bitset
+
+#if !defined(__cpp_lib_hardened_common_iterator)
+# if (defined(__glibcxx_ranges) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_common_iterator 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_common_iterator)
+#   define __cpp_lib_hardened_common_iterator 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_common_iterator) */
+#undef __glibcxx_want_hardened_common_iterator
+
+#if !defined(__cpp_lib_hardened_counted_iterator)
+# if (defined(__glibcxx_ranges) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_counted_iterator 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_counted_iterator)
+#   define __cpp_lib_hardened_counted_iterator 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_counted_iterator) */
+#undef __glibcxx_want_hardened_counted_iterator
+
+#if !defined(__cpp_lib_hardened_deque)
+# if (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_deque 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_deque)
+#   define __cpp_lib_hardened_deque 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_deque) */
+#undef __glibcxx_want_hardened_deque
+
+#if !defined(__cpp_lib_hardened_expected)
+# if (defined(__glibcxx_expected) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_expected 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_expected)
+#   define __cpp_lib_hardened_expected 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_expected) */
+#undef __glibcxx_want_hardened_expected
+
+#if !defined(__cpp_lib_hardened_forward_list)
+# if (__cplusplus >= 201103L) && (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_forward_list 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_forward_list)
+#   define __cpp_lib_hardened_forward_list 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_forward_list) */
+#undef __glibcxx_want_hardened_forward_list
+
+#if !defined(__cpp_lib_hardened_inplace_vector)
+# if (defined(__glibcxx_inplace_vector) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_inplace_vector 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_inplace_vector)
+#   define __cpp_lib_hardened_inplace_vector 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_inplace_vector) */
+#undef __glibcxx_want_hardened_inplace_vector
+
+#if !defined(__cpp_lib_hardened_list)
+# if (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_list 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_list)
+#   define __cpp_lib_hardened_list 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_list) */
+#undef __glibcxx_want_hardened_list
+
 #if !defined(__cpp_lib_hardened_mdspan)
 # if (defined(__glibcxx_mdspan) && defined(_GLIBCXX_ASSERTIONS))
 #  define __glibcxx_hardened_mdspan 202502L
@@ -2720,4 +2840,64 @@
 #endif /* !defined(__cpp_lib_hardened_mdspan) */
 #undef __glibcxx_want_hardened_mdspan
 
+#if !defined(__cpp_lib_hardened_optional)
+# if (defined(__glibcxx_optional) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_optional 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_optional)
+#   define __cpp_lib_hardened_optional 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_optional) */
+#undef __glibcxx_want_hardened_optional
+
+#if !defined(__cpp_lib_hardened_shared_ptr_array)
+# if (defined(__glibcxx_shared_ptr_arrays) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_shared_ptr_array 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_shared_ptr_array)
+#   define __cpp_lib_hardened_shared_ptr_array 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_shared_ptr_array) */
+#undef __glibcxx_want_hardened_shared_ptr_array
+
+#if !defined(__cpp_lib_hardened_span)
+# if (defined(__glibcxx_span) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_span 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_span)
+#   define __cpp_lib_hardened_span 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_span) */
+#undef __glibcxx_want_hardened_span
+
+#if !defined(__cpp_lib_hardened_valarray)
+# if (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_valarray 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_valarray)
+#   define __cpp_lib_hardened_valarray 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_valarray) */
+#undef __glibcxx_want_hardened_valarray
+
+#if !defined(__cpp_lib_hardened_vector)
+# if (defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_vector 202502L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_hardened_vector)
+#   define __cpp_lib_hardened_vector 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_vector) */
+#undef __glibcxx_want_hardened_vector
+
+#if !defined(__cpp_lib_hardened_view_interface)
+# if (defined(__glibcxx_ranges) && defined(_GLIBCXX_ASSERTIONS))
+#  define __glibcxx_hardened_view_interface 202502L
+#  if defined(__glibcxx_want_all) || 
defined(__glibcxx_want_hardened_view_interface)
+#   define __cpp_lib_hardened_view_interface 202502L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_hardened_view_interface) */
+#undef __glibcxx_want_hardened_view_interface
+
 #undef __glibcxx_want_all
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index 22f6251d4fe3..5d3edbea6495 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -49,6 +49,7 @@
 
 #define __glibcxx_want_array_constexpr
 #define __glibcxx_want_freestanding_array
+#define __glibcxx_want_hardened_array
 #define __glibcxx_want_nonmember_container_access
 #define __glibcxx_want_to_array
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 64dae5be8bf9..a8cb337f4b15 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -62,6 +62,7 @@
 
 #define __glibcxx_want_constexpr_bitset
 #define __glibcxx_want_bitset  // ...construct from string_view
+#define __glibcxx_want_hardened_bitset
 #include <bits/version.h>
 
 #ifdef __cpp_lib_bitset // ...construct from string_view
diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque
index 3899b68e7367..3b2f34fc7075 100644
--- a/libstdc++-v3/include/std/deque
+++ b/libstdc++-v3/include/std/deque
@@ -75,6 +75,7 @@
 #define __glibcxx_want_allocator_traits_is_always_equal
 #define __glibcxx_want_containers_ranges
 #define __glibcxx_want_erase_if
+#define __glibcxx_want_hardened_deque
 #define __glibcxx_want_nonmember_container_access
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/std/expected 
b/libstdc++-v3/include/std/expected
index 21522850d7ae..fe4e1ecbf0ec 100644
--- a/libstdc++-v3/include/std/expected
+++ b/libstdc++-v3/include/std/expected
@@ -37,6 +37,7 @@
 #define __glibcxx_want_freestanding_expected
 #define __glibcxx_want_constrained_equality
 #define __glibcxx_want_constexpr_exceptions
+#define __glibcxx_want_hardened_expected
 #include <bits/version.h>
 
 #ifdef __cpp_lib_expected // C++ >= 23 && __cpp_concepts >= 202002L
diff --git a/libstdc++-v3/include/std/forward_list 
b/libstdc++-v3/include/std/forward_list
index ff0c58455cf5..e24c1573e0ad 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -51,6 +51,7 @@
 #define __glibcxx_want_allocator_traits_is_always_equal
 #define __glibcxx_want_containers_ranges
 #define __glibcxx_want_erase_if
+#define __glibcxx_want_hardened_forward_list
 #define __glibcxx_want_incomplete_container_elements
 #define __glibcxx_want_list_remove_return_type
 #define __glibcxx_want_nonmember_container_access
diff --git a/libstdc++-v3/include/std/inplace_vector 
b/libstdc++-v3/include/std/inplace_vector
index caf9c2032452..8bd890042969 100644
--- a/libstdc++-v3/include/std/inplace_vector
+++ b/libstdc++-v3/include/std/inplace_vector
@@ -32,6 +32,7 @@
 
 #pragma GCC system_header
 
+#define __glibcxx_want_hardened_inplace_vector
 #define __glibcxx_want_inplace_vector
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/std/iterator 
b/libstdc++-v3/include/std/iterator
index 96696cc53593..3d2dc8bbe9e4 100644
--- a/libstdc++-v3/include/std/iterator
+++ b/libstdc++-v3/include/std/iterator
@@ -71,6 +71,8 @@
 
 #define __glibcxx_want_array_constexpr
 #define __glibcxx_want_constexpr_iterator
+#define __glibcxx_want_hardened_common_iterator
+#define __glibcxx_want_hardened_counted_iterator
 #define __glibcxx_want_make_reverse_iterator
 #define __glibcxx_want_move_iterator_concept
 #define __glibcxx_want_nonmember_container_access
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index a3e7c81680a9..29d8fce698bc 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -75,6 +75,7 @@
 #define __glibcxx_want_allocator_traits_is_always_equal
 #define __glibcxx_want_containers_ranges
 #define __glibcxx_want_erase_if
+#define __glibcxx_want_hardened_list
 #define __glibcxx_want_incomplete_container_elements
 #define __glibcxx_want_list_remove_return_type
 #define __glibcxx_want_nonmember_container_access
diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory
index cbe9f5ad2007..9343b3497315 100644
--- a/libstdc++-v3/include/std/memory
+++ b/libstdc++-v3/include/std/memory
@@ -110,6 +110,7 @@
 #define __glibcxx_want_constexpr_dynamic_alloc
 #define __glibcxx_want_constexpr_memory
 #define __glibcxx_want_enable_shared_from_this
+#define __glibcxx_want_hardened_shared_ptr_array
 #define __glibcxx_want_indirect
 #define __glibcxx_want_is_sufficiently_aligned
 #define __glibcxx_want_make_unique
diff --git a/libstdc++-v3/include/std/optional 
b/libstdc++-v3/include/std/optional
index dec1a50413ab..221beb2446d6 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -39,6 +39,7 @@
 #define __glibcxx_want_optional_range_support
 #define __glibcxx_want_constrained_equality
 #define __glibcxx_want_constexpr_exceptions
+#define __glibcxx_want_hardened_optional
 #include <bits/version.h>
 
 #ifdef __cpp_lib_optional // C++ >= 17
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 7d8b37f8c5cf..39a50b03e457 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -56,6 +56,7 @@
 #include <bits/refwrap.h>
 
 #define __glibcxx_want_algorithm_default_value_type
+#define __glibcxx_want_hardened_view_interface
 #define __glibcxx_want_ranges
 #define __glibcxx_want_ranges_as_const
 #define __glibcxx_want_ranges_as_rvalue
diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span
index aaa7a485be8c..2b978dad8a4d 100644
--- a/libstdc++-v3/include/std/span
+++ b/libstdc++-v3/include/std/span
@@ -40,6 +40,7 @@
 
 #define __glibcxx_want_span
 #define __glibcxx_want_span_initializer_list
+#define __glibcxx_want_hardened_span
 #include <bits/version.h>
 
 #ifdef __cpp_lib_span // C++ >= 20 && concepts
diff --git a/libstdc++-v3/include/std/stacktrace 
b/libstdc++-v3/include/std/stacktrace
index 79941d93b88f..22d8b804a5e9 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -34,6 +34,7 @@
 
 #define __glibcxx_want_stacktrace
 #define __glibcxx_want_formatters
+#define __glibcxx_want_hardened_basic_stacktrace
 #include <bits/version.h>
 
 #ifdef __cpp_lib_stacktrace // C++ >= 23 && hosted && HAVE_STACKTRACE
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index c2b37391fc7a..1a622b7aebd6 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -72,6 +72,7 @@
 #define __glibcxx_want_constexpr_string
 #define __glibcxx_want_containers_ranges
 #define __glibcxx_want_erase_if
+#define __glibcxx_want_hardened_basic_string
 #define __glibcxx_want_nonmember_container_access
 #define __glibcxx_want_string_resize_and_overwrite
 #define __glibcxx_want_string_subview
diff --git a/libstdc++-v3/include/std/string_view 
b/libstdc++-v3/include/std/string_view
index 81b0011245b5..ce6aee290524 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -40,6 +40,7 @@
 #define __glibcxx_want_constexpr_char_traits
 #define __glibcxx_want_constexpr_string_view
 #define __glibcxx_want_freestanding_string_view
+#define __glibcxx_want_hardened_basic_string_view
 #define __glibcxx_want_starts_ends_with
 #define __glibcxx_want_string_contains
 #define __glibcxx_want_string_subview
diff --git a/libstdc++-v3/include/std/valarray 
b/libstdc++-v3/include/std/valarray
index 5a1f5c0ac5e8..1e2254d5c72d 100644
--- a/libstdc++-v3/include/std/valarray
+++ b/libstdc++-v3/include/std/valarray
@@ -46,6 +46,7 @@
 #include <bits/range_access.h>
 #endif
 
+#define __glibcxx_want_hardened_valarray
 #define __glibcxx_want_valarray
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector
index 343483e95191..86e42b22ea5b 100644
--- a/libstdc++-v3/include/std/vector
+++ b/libstdc++-v3/include/std/vector
@@ -83,6 +83,7 @@
 #define __glibcxx_want_constexpr_vector
 #define __glibcxx_want_containers_ranges
 #define __glibcxx_want_erase_if
+#define __glibcxx_want_hardened_vector
 #define __glibcxx_want_incomplete_container_elements
 #define __glibcxx_want_nonmember_container_access
 #include <bits/version.h>
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 c71ddf91f645..0772581226de 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
@@ -26,6 +26,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 *-*-* } 396 }
-// { dg-error "static assertion failed" "" { target *-*-* } 405 }
-// { dg-error "static assertion failed" "" { target *-*-* } 414 }
+// { dg-error "static assertion failed" "" { target *-*-* } 397 }
+// { dg-error "static assertion failed" "" { target *-*-* } 406 }
+// { dg-error "static assertion failed" "" { target *-*-* } 415 }
-- 
2.54.0

Reply via email to