diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index 9c28ebfb345..739017aaaad 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -120,6 +120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  using __type = typename __result<_Tp>::type;
 
 	template<std::__detail::__dereferenceable _Tp>
+	  [[nodiscard]]
 	  constexpr __type<_Tp>
 	  operator()(_Tp&& __e) const
 	  noexcept(_S_noexcept<_Tp>())
diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
index 71ad28c3ab0..ab2d4f8652c 100644
--- a/libstdc++-v3/include/bits/range_access.h
+++ b/libstdc++-v3/include/bits/range_access.h
@@ -47,6 +47,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     begin(_Container& __cont) -> decltype(__cont.begin())
     { return __cont.begin(); }
@@ -57,6 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     begin(const _Container& __cont) -> decltype(__cont.begin())
     { return __cont.begin(); }
@@ -67,6 +69,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     end(_Container& __cont) -> decltype(__cont.end())
     { return __cont.end(); }
@@ -77,6 +80,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     end(const _Container& __cont) -> decltype(__cont.end())
     { return __cont.end(); }
@@ -86,6 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __arr  Array.
    */
   template<typename _Tp, size_t _Nm>
+    [[__nodiscard__]]
     inline _GLIBCXX14_CONSTEXPR _Tp*
     begin(_Tp (&__arr)[_Nm]) noexcept
     { return __arr; }
@@ -96,6 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __arr  Array.
    */
   template<typename _Tp, size_t _Nm>
+    [[__nodiscard__]]
     inline _GLIBCXX14_CONSTEXPR _Tp*
     end(_Tp (&__arr)[_Nm]) noexcept
     { return __arr + _Nm; }
@@ -115,6 +121,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline constexpr auto
     cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont)))
       -> decltype(std::begin(__cont))
@@ -126,6 +133,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline constexpr auto
     cend(const _Container& __cont) noexcept(noexcept(std::end(__cont)))
       -> decltype(std::end(__cont))
@@ -137,6 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     rbegin(_Container& __cont) -> decltype(__cont.rbegin())
     { return __cont.rbegin(); }
@@ -147,6 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     rbegin(const _Container& __cont) -> decltype(__cont.rbegin())
     { return __cont.rbegin(); }
@@ -157,6 +167,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     rend(_Container& __cont) -> decltype(__cont.rend())
     { return __cont.rend(); }
@@ -167,6 +178,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     rend(const _Container& __cont) -> decltype(__cont.rend())
     { return __cont.rend(); }
@@ -177,6 +189,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __arr  Array.
    */
   template<typename _Tp, size_t _Nm>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*>
     rbegin(_Tp (&__arr)[_Nm]) noexcept
     { return reverse_iterator<_Tp*>(__arr + _Nm); }
@@ -187,6 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __arr  Array.
    */
   template<typename _Tp, size_t _Nm>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*>
     rend(_Tp (&__arr)[_Nm]) noexcept
     { return reverse_iterator<_Tp*>(__arr); }
@@ -197,6 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __il  initializer_list.
    */
   template<typename _Tp>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR reverse_iterator<const _Tp*>
     rbegin(initializer_list<_Tp> __il) noexcept
     { return reverse_iterator<const _Tp*>(__il.end()); }
@@ -207,6 +222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __il  initializer_list.
    */
   template<typename _Tp>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR reverse_iterator<const _Tp*>
     rend(initializer_list<_Tp> __il) noexcept
     { return reverse_iterator<const _Tp*>(__il.begin()); }
@@ -217,6 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     crbegin(const _Container& __cont) -> decltype(std::rbegin(__cont))
     { return std::rbegin(__cont); }
@@ -227,6 +244,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template<typename _Container>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     crend(const _Container& __cont) -> decltype(std::rend(__cont))
     { return std::rend(__cont); }
@@ -241,6 +259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template <typename _Container>
+    [[nodiscard]]
     constexpr auto
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     -> decltype(__cont.size())
@@ -250,6 +269,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @brief  Return the size of an array.
    */
   template <typename _Tp, size_t _Nm>
+    [[nodiscard]]
     constexpr size_t
     size(const _Tp (&)[_Nm]) noexcept
     { return _Nm; }
@@ -286,6 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template <typename _Container>
+    [[nodiscard]]
     constexpr auto
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     -> decltype(__cont.data())
@@ -296,6 +317,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __cont  Container.
    */
   template <typename _Container>
+    [[nodiscard]]
     constexpr auto
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     -> decltype(__cont.data())
@@ -306,6 +328,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __array  Array.
    */
   template <typename _Tp, size_t _Nm>
+    [[nodiscard]]
     constexpr _Tp*
     data(_Tp (&__array)[_Nm]) noexcept
     { return __array; }
@@ -315,6 +338,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @param  __il  Initializer list.
    */
   template <typename _Tp>
+    [[nodiscard]]
     constexpr const _Tp*
     data(initializer_list<_Tp> __il) noexcept
     { return __il.begin(); }
@@ -322,6 +346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cplusplus > 201703L
 #define __cpp_lib_ssize 201902L
   template<typename _Container>
+    [[nodiscard]]
     constexpr auto
     ssize(const _Container& __cont)
     noexcept(noexcept(__cont.size()))
@@ -332,6 +357,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<typename _Tp, ptrdiff_t _Num>
+    [[nodiscard]]
     constexpr ptrdiff_t
     ssize(const _Tp (&)[_Num]) noexcept
     { return _Num; }
diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index 9d749c8d9b7..614b6edf9df 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -110,6 +110,7 @@ namespace ranges
       template<__maybe_borrowed_range _Tp>
 	requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
 	  || __adl_begin<_Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>())
 	{
@@ -161,6 +162,7 @@ namespace ranges
       template<__maybe_borrowed_range _Tp>
 	requires is_bounded_array_v<remove_reference_t<_Tp>>
 	  || __member_end<_Tp> || __adl_end<_Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>())
 	{
@@ -192,6 +194,7 @@ namespace ranges
     struct _CBegin
     {
       template<typename _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __e) const
 	noexcept(noexcept(_Begin{}(__cust_access::__as_const<_Tp>(__e))))
@@ -204,6 +207,7 @@ namespace ranges
     struct _CEnd final
     {
       template<typename _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __e) const
 	noexcept(noexcept(_End{}(__cust_access::__as_const<_Tp>(__e))))
@@ -263,6 +267,7 @@ namespace ranges
     public:
       template<__maybe_borrowed_range _Tp>
 	requires __member_rbegin<_Tp> || __adl_rbegin<_Tp> || __reversable<_Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const
 	noexcept(_S_noexcept<_Tp&>())
@@ -321,6 +326,7 @@ namespace ranges
     public:
       template<__maybe_borrowed_range _Tp>
 	requires __member_rend<_Tp> || __adl_rend<_Tp> || __reversable<_Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const
 	noexcept(_S_noexcept<_Tp&>())
@@ -337,6 +343,7 @@ namespace ranges
     struct _CRBegin
     {
       template<typename _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __e) const
 	noexcept(noexcept(_RBegin{}(__cust_access::__as_const<_Tp>(__e))))
@@ -349,6 +356,7 @@ namespace ranges
     struct _CREnd
     {
       template<typename _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __e) const
 	noexcept(noexcept(_REnd{}(__cust_access::__as_const<_Tp>(__e))))
@@ -408,6 +416,7 @@ namespace ranges
       template<typename _Tp>
 	requires is_bounded_array_v<remove_reference_t<_Tp>>
 	  || __member_size<_Tp> || __adl_size<_Tp> || __sentinel_size<_Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>())
 	{
@@ -428,6 +437,7 @@ namespace ranges
       // 3403. Domain of ranges::ssize(E) doesn't match ranges::size(E)
       template<typename _Tp>
 	requires requires (_Tp& __t) { _Size{}(__t); }
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const noexcept(noexcept(_Size{}(__t)))
 	{
@@ -487,6 +497,7 @@ namespace ranges
       template<typename _Tp>
 	requires __member_empty<_Tp> || __size0_empty<_Tp>
 	  || __eq_iter_empty<_Tp>
+	[[nodiscard]]
 	constexpr bool
 	operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>())
 	{
@@ -528,6 +539,7 @@ namespace ranges
     public:
       template<__maybe_borrowed_range _Tp>
 	requires __member_data<_Tp> || __begin_data<_Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>())
 	{
@@ -541,6 +553,7 @@ namespace ranges
     struct _CData
     {
       template<typename _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Tp&& __e) const
 	noexcept(noexcept(_Data{}(__cust_access::__as_const<_Tp>(__e))))
@@ -782,6 +795,7 @@ namespace ranges
   struct __distance_fn final
   {
     template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
+      [[nodiscard]]
       constexpr iter_difference_t<_It>
       operator()(_It __first, _Sent __last) const
       {
@@ -800,6 +814,7 @@ namespace ranges
       }
 
     template<range _Range>
+      [[nodiscard]]
       constexpr range_difference_t<_Range>
       operator()(_Range&& __r) const
       {
@@ -817,6 +832,7 @@ namespace ranges
   struct __next_fn final
   {
     template<input_or_output_iterator _It>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x) const
       {
@@ -825,6 +841,7 @@ namespace ranges
       }
 
     template<input_or_output_iterator _It>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x, iter_difference_t<_It> __n) const
       {
@@ -833,6 +850,7 @@ namespace ranges
       }
 
     template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x, _Sent __bound) const
       {
@@ -841,6 +859,7 @@ namespace ranges
       }
 
     template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x, iter_difference_t<_It> __n, _Sent __bound) const
       {
@@ -856,6 +875,7 @@ namespace ranges
   struct __prev_fn final
   {
     template<bidirectional_iterator _It>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x) const
       {
@@ -864,6 +884,7 @@ namespace ranges
       }
 
     template<bidirectional_iterator _It>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x, iter_difference_t<_It> __n) const
       {
@@ -872,6 +893,7 @@ namespace ranges
       }
 
     template<bidirectional_iterator _It>
+      [[nodiscard]]
       constexpr _It
       operator()(_It __x, iter_difference_t<_It> __n, _It __bound) const
       {
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 7fe727d8093..3773d600b8f 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -223,6 +223,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       /**
        *  @return  @c current, the %iterator used for underlying work.
       */
+      _GLIBCXX_NODISCARD
       _GLIBCXX17_CONSTEXPR iterator_type
       base() const
       { return current; }
@@ -237,6 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *           @c *x remains valid after @c x has been modified or
        *           destroyed. This is a bug: http://gcc.gnu.org/PR51823
       */
+      _GLIBCXX_NODISCARD
       _GLIBCXX17_CONSTEXPR reference
       operator*() const
       {
@@ -249,6 +251,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        *  This requires that @c --current is dereferenceable.
       */
+      _GLIBCXX_NODISCARD
       _GLIBCXX17_CONSTEXPR pointer
       operator->() const
 #if __cplusplus > 201703L && __cpp_concepts >= 201907L
@@ -318,6 +321,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        *  The underlying iterator must be a Random Access Iterator.
       */
+      _GLIBCXX_NODISCARD
       _GLIBCXX17_CONSTEXPR reverse_iterator
       operator+(difference_type __n) const
       { return reverse_iterator(current - __n); }
@@ -340,6 +344,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        *  The underlying iterator must be a Random Access Iterator.
       */
+      _GLIBCXX_NODISCARD
       _GLIBCXX17_CONSTEXPR reverse_iterator
       operator-(difference_type __n) const
       { return reverse_iterator(current + __n); }
@@ -362,11 +367,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        *  The underlying iterator must be a Random Access Iterator.
       */
+      _GLIBCXX_NODISCARD
       _GLIBCXX17_CONSTEXPR reference
       operator[](difference_type __n) const
       { return *(*this + __n); }
 
 #if __cplusplus > 201703L && __cpp_lib_concepts
+      [[nodiscard]]
       friend constexpr iter_rvalue_reference_t<_Iterator>
       iter_move(const reverse_iterator& __i)
       noexcept(is_nothrow_copy_constructible_v<_Iterator>
@@ -415,36 +422,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
 #if __cplusplus <= 201703L || ! defined __cpp_lib_concepts
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator==(const reverse_iterator<_Iterator>& __x,
 	       const reverse_iterator<_Iterator>& __y)
     { return __x.base() == __y.base(); }
 
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator<(const reverse_iterator<_Iterator>& __x,
 	      const reverse_iterator<_Iterator>& __y)
     { return __y.base() < __x.base(); }
 
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator!=(const reverse_iterator<_Iterator>& __x,
 	       const reverse_iterator<_Iterator>& __y)
     { return !(__x == __y); }
 
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator>(const reverse_iterator<_Iterator>& __x,
 	      const reverse_iterator<_Iterator>& __y)
     { return __y < __x; }
 
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator<=(const reverse_iterator<_Iterator>& __x,
 	       const reverse_iterator<_Iterator>& __y)
     { return !(__y < __x); }
 
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator>=(const reverse_iterator<_Iterator>& __x,
 	       const reverse_iterator<_Iterator>& __y)
@@ -454,24 +467,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // DR 280. Comparison of reverse_iterator to const reverse_iterator.
 
   template<typename _IteratorL, typename _IteratorR>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator==(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
     { return __x.base() == __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator<(const reverse_iterator<_IteratorL>& __x,
 	      const reverse_iterator<_IteratorR>& __y)
     { return __x.base() > __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator!=(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
     { return __x.base() != __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator>(const reverse_iterator<_IteratorL>& __x,
 	      const reverse_iterator<_IteratorR>& __y)
@@ -484,12 +501,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() >= __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR bool
     operator>=(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
     { return __x.base() <= __y.base(); }
 #else // C++20
   template<typename _IteratorL, typename _IteratorR>
+    [[nodiscard]]
     constexpr bool
     operator==(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
@@ -497,6 +516,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() == __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[nodiscard]]
     constexpr bool
     operator!=(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
@@ -504,6 +524,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() != __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[nodiscard]]
     constexpr bool
     operator<(const reverse_iterator<_IteratorL>& __x,
 	      const reverse_iterator<_IteratorR>& __y)
@@ -511,6 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() > __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[nodiscard]]
     constexpr bool
     operator>(const reverse_iterator<_IteratorL>& __x,
 	      const reverse_iterator<_IteratorR>& __y)
@@ -518,6 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() < __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[nodiscard]]
     constexpr bool
     operator<=(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
@@ -525,6 +548,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() >= __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[nodiscard]]
     constexpr bool
     operator>=(const reverse_iterator<_IteratorL>& __x,
 	       const reverse_iterator<_IteratorR>& __y)
@@ -533,6 +557,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _IteratorL,
 	   three_way_comparable_with<_IteratorL> _IteratorR>
+    [[nodiscard]]
     constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
     operator<=>(const reverse_iterator<_IteratorL>& __x,
 		const reverse_iterator<_IteratorR>& __y)
@@ -556,6 +581,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 685. reverse_iterator/move_iterator difference has invalid signatures
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     operator-(const reverse_iterator<_IteratorL>& __x,
 	      const reverse_iterator<_IteratorR>& __y)
@@ -564,6 +590,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   template<typename _Iterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
 	      const reverse_iterator<_Iterator>& __x)
@@ -583,6 +610,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // DR 2285. make_reverse_iterator
   /// Generator function for reverse_iterator.
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
     make_reverse_iterator(_Iterator __i)
     { return reverse_iterator<_Iterator>(__i); }
@@ -683,7 +711,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
       /// Simply returns *this.
-      _GLIBCXX20_CONSTEXPR
+      _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       back_insert_iterator&
       operator*()
       { return *this; }
@@ -713,7 +741,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  types for you.
   */
   template<typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline back_insert_iterator<_Container>
     back_inserter(_Container& __x)
     { return back_insert_iterator<_Container>(__x); }
@@ -784,7 +812,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
       /// Simply returns *this.
-      _GLIBCXX20_CONSTEXPR
+      _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       front_insert_iterator&
       operator*()
       { return *this; }
@@ -814,7 +842,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  types for you.
   */
   template<typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline front_insert_iterator<_Container>
     front_inserter(_Container& __x)
     { return front_insert_iterator<_Container>(__x); }
@@ -914,7 +942,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
       /// Simply returns *this.
-      _GLIBCXX20_CONSTEXPR
+      _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       insert_iterator&
       operator*()
       { return *this; }
@@ -946,11 +974,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
 #if __cplusplus > 201703L && defined __cpp_lib_concepts
   template<typename _Container>
+    [[nodiscard]]
     constexpr insert_iterator<_Container>
     inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i)
     { return insert_iterator<_Container>(__x, __i); }
 #else
   template<typename _Container>
+    _GLIBCXX_NODISCARD
     inline insert_iterator<_Container>
     inserter(_Container& __x, typename _Container::iterator __i)
     { return insert_iterator<_Container>(__x, __i); }
@@ -1090,6 +1120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _IteratorL, typename _IteratorR, typename _Container>
     requires requires (_IteratorL __lhs, _IteratorR __rhs)
     { { __lhs == __rhs } -> std::convertible_to<bool>; }
+    [[nodiscard]]
     constexpr bool
     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	       const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1097,6 +1128,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() == __rhs.base(); }
 
   template<typename _IteratorL, typename _IteratorR, typename _Container>
+    [[nodiscard]]
     constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL>
     operator<=>(const __normal_iterator<_IteratorL, _Container>& __lhs,
 		const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1105,7 +1137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #else
    // Forward iterator requirements
   template<typename _IteratorL, typename _IteratorR, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	       const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1113,7 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() == __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
 	       const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1121,7 +1153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() == __rhs.base(); }
 
   template<typename _IteratorL, typename _IteratorR, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	       const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1129,7 +1161,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() != __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
 	       const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1138,6 +1170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Random access iterator requirements
   template<typename _IteratorL, typename _IteratorR, typename _Container>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	      const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1145,7 +1178,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() < __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
 	      const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1153,6 +1186,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() < __rhs.base(); }
 
   template<typename _IteratorL, typename _IteratorR, typename _Container>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	      const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1160,7 +1194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() > __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
 	      const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1168,6 +1202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() > __rhs.base(); }
 
   template<typename _IteratorL, typename _IteratorR, typename _Container>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	       const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1175,7 +1210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() <= __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
 	       const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1183,6 +1218,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() <= __rhs.base(); }
 
   template<typename _IteratorL, typename _IteratorR, typename _Container>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	       const __normal_iterator<_IteratorR, _Container>& __rhs)
@@ -1190,7 +1226,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() >= __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline bool
     operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
 	       const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1205,7 +1241,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _IteratorL, typename _IteratorR, typename _Container>
 #if __cplusplus >= 201103L
     // DR 685.
-    _GLIBCXX20_CONSTEXPR
+    [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
     inline auto
     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
 	      const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
@@ -1218,7 +1254,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() - __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline typename __normal_iterator<_Iterator, _Container>::difference_type
     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
 	      const __normal_iterator<_Iterator, _Container>& __rhs)
@@ -1226,7 +1262,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs.base() - __rhs.base(); }
 
   template<typename _Iterator, typename _Container>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline __normal_iterator<_Iterator, _Container>
     operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
 	      __n, const __normal_iterator<_Iterator, _Container>& __i)
@@ -1284,6 +1320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  return *this;
 	}
 
+      [[nodiscard]]
       constexpr _Sent
       base() const
       noexcept(is_nothrow_copy_constructible_v<_Sent>)
@@ -1397,19 +1434,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
 
 #if __cplusplus <= 201703L
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR iterator_type
       base() const
       { return _M_current; }
 #else
+      [[nodiscard]]
       constexpr const iterator_type&
       base() const & noexcept
       { return _M_current; }
 
+      [[nodiscard]]
       constexpr iterator_type
       base() &&
       { return std::move(_M_current); }
 #endif
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reference
       operator*() const
 #if __cplusplus > 201703L && __cpp_lib_concepts
@@ -1418,6 +1459,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return static_cast<reference>(*_M_current); }
 #endif
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR pointer
       operator->() const
       { return _M_current; }
@@ -1458,6 +1500,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return __tmp;
       }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR move_iterator
       operator+(difference_type __n) const
       { return move_iterator(_M_current + __n); }
@@ -1469,6 +1512,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *this;
       }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR move_iterator
       operator-(difference_type __n) const
       { return move_iterator(_M_current - __n); }
@@ -1480,6 +1524,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *this;
       }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reference
       operator[](difference_type __n) const
 #if __cplusplus > 201703L && __cpp_lib_concepts
@@ -1490,20 +1535,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cplusplus > 201703L && __cpp_lib_concepts
       template<sentinel_for<_Iterator> _Sent>
+	[[nodiscard]]
 	friend constexpr bool
 	operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y)
 	{ return __x.base() == __y.base(); }
 
       template<sized_sentinel_for<_Iterator> _Sent>
+	[[nodiscard]]
 	friend constexpr iter_difference_t<_Iterator>
 	operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y)
 	{ return __x.base() - __y.base(); }
 
       template<sized_sentinel_for<_Iterator> _Sent>
+	[[nodiscard]]
 	friend constexpr iter_difference_t<_Iterator>
 	operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y)
 	{ return __x.base() - __y.base(); }
 
+      [[nodiscard]]
       friend constexpr iter_rvalue_reference_t<_Iterator>
       iter_move(const move_iterator& __i)
       noexcept(noexcept(ranges::iter_move(__i._M_current)))
@@ -1518,6 +1567,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator==(const move_iterator<_IteratorL>& __x,
 	       const move_iterator<_IteratorR>& __y)
@@ -1529,12 +1579,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cpp_lib_three_way_comparison
   template<typename _IteratorL,
 	   three_way_comparable_with<_IteratorL> _IteratorR>
+    [[__nodiscard__]]
     constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
     operator<=>(const move_iterator<_IteratorL>& __x,
 		const move_iterator<_IteratorR>& __y)
     { return __x.base() <=> __y.base(); }
 #else
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator!=(const move_iterator<_IteratorL>& __x,
 	       const move_iterator<_IteratorR>& __y)
@@ -1542,6 +1594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator<(const move_iterator<_IteratorL>& __x,
 	      const move_iterator<_IteratorR>& __y)
@@ -1551,6 +1604,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() < __y.base(); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator<=(const move_iterator<_IteratorL>& __x,
 	       const move_iterator<_IteratorR>& __y)
@@ -1560,6 +1614,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return !(__y < __x); }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator>(const move_iterator<_IteratorL>& __x,
 	      const move_iterator<_IteratorR>& __y)
@@ -1569,6 +1624,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __y < __x; }
 
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator>=(const move_iterator<_IteratorL>& __x,
 	       const move_iterator<_IteratorR>& __y)
@@ -1586,36 +1642,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // prefer them to greedy unconstrained function templates.
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator==(const move_iterator<_Iterator>& __x,
 	       const move_iterator<_Iterator>& __y)
     { return __x.base() == __y.base(); }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator!=(const move_iterator<_Iterator>& __x,
 	       const move_iterator<_Iterator>& __y)
     { return !(__x == __y); }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator<(const move_iterator<_Iterator>& __x,
 	      const move_iterator<_Iterator>& __y)
     { return __x.base() < __y.base(); }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator<=(const move_iterator<_Iterator>& __x,
 	       const move_iterator<_Iterator>& __y)
     { return !(__y < __x); }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator>(const move_iterator<_Iterator>& __x,
 	      const move_iterator<_Iterator>& __y)
     { return __y < __x; }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR bool
     operator>=(const move_iterator<_Iterator>& __x,
 	       const move_iterator<_Iterator>& __y)
@@ -1624,6 +1686,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // DR 685.
   template<typename _IteratorL, typename _IteratorR>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR auto
     operator-(const move_iterator<_IteratorL>& __x,
 	      const move_iterator<_IteratorR>& __y)
@@ -1631,12 +1694,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __x.base() - __y.base(); }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
     operator+(typename move_iterator<_Iterator>::difference_type __n,
 	      const move_iterator<_Iterator>& __x)
     { return __x + __n; }
 
   template<typename _Iterator>
+    [[__nodiscard__]]
     inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
     make_move_iterator(_Iterator __i)
     { return move_iterator<_Iterator>(std::move(__i)); }
@@ -1857,6 +1922,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+    [[nodiscard]]
     decltype(auto)
     operator*()
     {
@@ -1864,6 +1930,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return *_M_it;
     }
 
+    [[nodiscard]]
     decltype(auto)
     operator*() const requires __detail::__dereferenceable<const _It>
     {
@@ -1871,6 +1938,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return *_M_it;
     }
 
+    [[nodiscard]]
     decltype(auto)
     operator->() const requires __detail::__common_iter_has_arrow<_It>
     {
@@ -1916,6 +1984,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<typename _It2, sentinel_for<_It> _Sent2>
       requires sentinel_for<_Sent, _It2>
+      [[nodiscard]]
       friend bool
       operator==(const common_iterator& __x,
 		 const common_iterator<_It2, _Sent2>& __y)
@@ -1938,6 +2007,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<typename _It2, sentinel_for<_It> _Sent2>
       requires sentinel_for<_Sent, _It2> && equality_comparable_with<_It, _It2>
+      [[nodiscard]]
       friend bool
       operator==(const common_iterator& __x,
 		 const common_iterator<_It2, _Sent2>& __y)
@@ -1961,6 +2031,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<sized_sentinel_for<_It> _It2, sized_sentinel_for<_It> _Sent2>
       requires sized_sentinel_for<_Sent, _It2>
+      [[nodiscard]]
       friend iter_difference_t<_It2>
       operator-(const common_iterator& __x,
 		const common_iterator<_It2, _Sent2>& __y)
@@ -1982,6 +2053,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  }
       }
 
+    [[nodiscard]]
     friend iter_rvalue_reference_t<_It>
     iter_move(const common_iterator& __i)
     noexcept(noexcept(ranges::iter_move(std::declval<const _It&>())))
@@ -2132,18 +2204,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  return *this;
 	}
 
+      [[nodiscard]]
       constexpr const _It&
       base() const & noexcept
       { return _M_current; }
 
+      [[nodiscard]]
       constexpr _It
       base() &&
       noexcept(is_nothrow_move_constructible_v<_It>)
       { return std::move(_M_current); }
 
+      [[nodiscard]]
       constexpr iter_difference_t<_It>
       count() const noexcept { return _M_length; }
 
+      [[nodiscard]]
       constexpr decltype(auto)
       operator*()
       noexcept(noexcept(*_M_current))
@@ -2152,6 +2228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *_M_current;
       }
 
+      [[nodiscard]]
       constexpr decltype(auto)
       operator*() const
       noexcept(noexcept(*_M_current))
@@ -2161,6 +2238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *_M_current;
       }
 
+      [[nodiscard]]
       constexpr auto
       operator->() const noexcept
       requires contiguous_iterator<_It>
@@ -2214,11 +2292,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return __tmp;
       }
 
+      [[nodiscard]]
       constexpr counted_iterator
       operator+(iter_difference_t<_It> __n) const
 	requires random_access_iterator<_It>
       { return counted_iterator(_M_current + __n, _M_length - __n); }
 
+      [[nodiscard]]
       friend constexpr counted_iterator
       operator+(iter_difference_t<_It> __n, const counted_iterator& __x)
       requires random_access_iterator<_It>
@@ -2234,21 +2314,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *this;
       }
 
+      [[nodiscard]]
       constexpr counted_iterator
       operator-(iter_difference_t<_It> __n) const
       requires random_access_iterator<_It>
       { return counted_iterator(_M_current - __n, _M_length + __n); }
 
       template<common_with<_It> _It2>
+	[[nodiscard]]
 	friend constexpr iter_difference_t<_It2>
 	operator-(const counted_iterator& __x,
 		  const counted_iterator<_It2>& __y)
 	{ return __y._M_length - __x._M_length; }
 
+      [[nodiscard]]
       friend constexpr iter_difference_t<_It>
       operator-(const counted_iterator& __x, default_sentinel_t)
       { return -__x._M_length; }
 
+      [[nodiscard]]
       friend constexpr iter_difference_t<_It>
       operator-(default_sentinel_t, const counted_iterator& __y)
       { return __y._M_length; }
@@ -2263,6 +2347,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *this;
       }
 
+      [[nodiscard]]
       constexpr decltype(auto)
       operator[](iter_difference_t<_It> __n) const
       noexcept(noexcept(_M_current[__n]))
@@ -2273,21 +2358,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       template<common_with<_It> _It2>
+	[[nodiscard]]
 	friend constexpr bool
 	operator==(const counted_iterator& __x,
 		   const counted_iterator<_It2>& __y)
 	{ return __x._M_length == __y._M_length; }
 
+      [[nodiscard]]
       friend constexpr bool
       operator==(const counted_iterator& __x, default_sentinel_t)
       { return __x._M_length == 0; }
 
       template<common_with<_It> _It2>
+	[[nodiscard]]
 	friend constexpr strong_ordering
 	operator<=>(const counted_iterator& __x,
 		    const counted_iterator<_It2>& __y)
 	{ return __y._M_length <=> __x._M_length; }
 
+      [[nodiscard]]
       friend constexpr iter_rvalue_reference_t<_It>
       iter_move(const counted_iterator& __i)
       noexcept(noexcept(ranges::iter_move(__i._M_current)))
diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
index fa8474f23c6..e5afab7f4fd 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
@@ -133,6 +133,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
    *  and are constant time.  For other %iterator classes they are linear time.
   */
   template<typename _InputIterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR
     typename iterator_traits<_InputIterator>::difference_type
     distance(_InputIterator __first, _InputIterator __last)
@@ -209,6 +210,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 #if __cplusplus >= 201103L
 
   template<typename _InputIterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR _InputIterator
     next(_InputIterator __x, typename
 	 iterator_traits<_InputIterator>::difference_type __n = 1)
@@ -220,6 +222,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
     }
 
   template<typename _BidirectionalIterator>
+    _GLIBCXX_NODISCARD
     inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
     prev(_BidirectionalIterator __x, typename
 	 iterator_traits<_BidirectionalIterator>::difference_type __n = 1) 
diff --git a/libstdc++-v3/include/bits/stream_iterator.h b/libstdc++-v3/include/bits/stream_iterator.h
index d07474d4996..d74c158f342 100644
--- a/libstdc++-v3/include/bits/stream_iterator.h
+++ b/libstdc++-v3/include/bits/stream_iterator.h
@@ -89,6 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~istream_iterator() = default;
 #endif
 
+      _GLIBCXX_NODISCARD
       const _Tp&
       operator*() const
       {
@@ -98,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return _M_value;
       }
 
+      _GLIBCXX_NODISCARD
       const _Tp*
       operator->() const { return std::__addressof((operator*())); }
 
@@ -143,17 +145,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       /// Return true if the iterators refer to the same stream,
       /// or are both at end-of-stream.
+      _GLIBCXX_NODISCARD
       friend bool
       operator==(const istream_iterator& __x, const istream_iterator& __y)
       { return __x._M_equal(__y); }
 
+#if __cpp_impl_three_way_comparison < 201907L
       /// Return true if the iterators refer to different streams,
       /// or if one is at end-of-stream and the other is not.
+      _GLIBCXX_NODISCARD
       friend bool
       operator!=(const istream_iterator& __x, const istream_iterator& __y)
       { return !__x._M_equal(__y); }
+#endif
 
 #if __cplusplus > 201703L && __cpp_lib_concepts
+      [[nodiscard]]
       friend bool
       operator==(const istream_iterator& __i, default_sentinel_t)
       { return !__i._M_stream; }
@@ -231,6 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *this;
       }
 
+      _GLIBCXX_NODISCARD
       ostream_iterator&
       operator*()
       { return *this; }
diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h
index cda596af40f..0a77d1a3da4 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -141,6 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ///  Return the current character pointed to by iterator.  This returns
       ///  streambuf.sgetc().  It cannot be assigned.  NB: The result of
       ///  operator*() on an end of stream is undefined.
+      _GLIBCXX_NODISCARD
       char_type
       operator*() const
       {
@@ -189,6 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // 110 istreambuf_iterator::equal not const
       // NB: there is also number 111 (NAD) relevant to this function.
       /// Return true both iterators are end or both are not end.
+      _GLIBCXX_NODISCARD
       bool
       equal(const istreambuf_iterator& __b) const
       { return _M_at_eof() == __b._M_at_eof(); }
@@ -215,6 +217,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
 #if __cplusplus > 201703L && __cpp_lib_concepts
+      [[nodiscard]]
       friend bool
       operator==(const istreambuf_iterator& __i, default_sentinel_t __s)
       { return __i._M_at_eof(); }
@@ -222,16 +225,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   template<typename _CharT, typename _Traits>
+    _GLIBCXX_NODISCARD
     inline bool
     operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
 	       const istreambuf_iterator<_CharT, _Traits>& __b)
     { return __a.equal(__b); }
 
+#if __cpp_impl_three_way_comparison < 201907L
   template<typename _CharT, typename _Traits>
+    _GLIBCXX_NODISCARD
     inline bool
     operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
 	       const istreambuf_iterator<_CharT, _Traits>& __b)
     { return !__a.equal(__b); }
+#endif
 
   /// Provides output iterator semantics for streambufs.
   template<typename _CharT, typename _Traits>
@@ -288,6 +295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       /// Return *this.
+      _GLIBCXX_NODISCARD
       ostreambuf_iterator&
       operator*()
       { return *this; }
@@ -303,6 +311,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return *this; }
 
       /// Return true if previous operator=() failed.
+      _GLIBCXX_NODISCARD
       bool
       failed() const _GLIBCXX_USE_NOEXCEPT
       { return _M_failed; }
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 5bdcd445a9e..03a3778bb52 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -645,6 +645,7 @@ namespace views
   struct _Single
   {
     template<typename _Tp>
+      [[nodiscard]]
       constexpr auto
       operator()(_Tp&& __e) const
       noexcept(noexcept(single_view<decay_t<_Tp>>(std::forward<_Tp>(__e))))
@@ -656,11 +657,13 @@ namespace views
   struct _Iota
   {
     template<typename _Tp>
+      [[nodiscard]]
       constexpr auto
       operator()(_Tp&& __e) const
       { return iota_view(std::forward<_Tp>(__e)); }
 
     template<typename _Tp, typename _Up>
+      [[nodiscard]]
       constexpr auto
       operator()(_Tp&& __e, _Up&& __f) const
       { return iota_view(std::forward<_Tp>(__e), std::forward<_Up>(__f)); }
@@ -1123,6 +1126,7 @@ namespace views::__adaptor
 	requires view<decay_t<_Range>>
 	  || __detail::__can_ref_view<_Range>
 	  || __detail::__can_subrange<_Range>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r) const
 	noexcept(_S_noexcept<_Range>())
@@ -1549,6 +1553,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Pred>
 	requires __detail::__can_filter_view<_Range, _Pred>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Pred&& __p) const
 	{
@@ -1926,6 +1931,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Fp>
 	requires __detail::__can_transform_view<_Range, _Fp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Fp&& __f) const
 	{
@@ -2107,6 +2113,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Tp>
 	requires __detail::__can_take_view<_Range, _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Tp&& __n) const
 	{
@@ -2234,6 +2241,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Pred>
 	requires __detail::__can_take_while_view<_Range, _Pred>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Pred&& __p) const
 	{
@@ -2354,6 +2362,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Tp>
 	requires __detail::__can_drop_view<_Range, _Tp>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Tp&& __n) const
 	{
@@ -2442,6 +2451,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Pred>
 	requires __detail::__can_drop_while_view<_Range, _Pred>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Pred&& __p) const
 	{
@@ -2804,6 +2814,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range>
 	requires __detail::__can_join_view<_Range>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r) const
 	{
@@ -3255,6 +3266,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Pattern>
 	requires __detail::__can_lazy_split_view<_Range, _Pattern>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Pattern&& __f) const
 	{
@@ -3463,6 +3475,7 @@ namespace views::__adaptor
     {
       template<viewable_range _Range, typename _Pattern>
 	requires __detail::__can_split_view<_Range, _Pattern>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r, _Pattern&& __f) const
 	{
@@ -3484,6 +3497,7 @@ namespace views::__adaptor
     struct _Counted
     {
       template<input_or_output_iterator _Iter>
+      [[nodiscard]]
       constexpr auto
       operator()(_Iter __i, iter_difference_t<_Iter> __n) const
       {
@@ -3605,6 +3619,7 @@ namespace views::__adaptor
       template<viewable_range _Range>
 	requires __detail::__already_common<_Range>
 	  || __detail::__can_common_view<_Range>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r) const
 	{
@@ -3727,6 +3742,7 @@ namespace views::__adaptor
 	requires __detail::__is_reverse_view<remove_cvref_t<_Range>>
 	  || __detail::__is_reversible_subrange<remove_cvref_t<_Range>>
 	  || __detail::__can_reverse_view<_Range>
+	[[nodiscard]]
 	constexpr auto
 	operator()(_Range&& __r) const
 	{
@@ -4125,6 +4141,7 @@ namespace views::__adaptor
       {
 	template<viewable_range _Range>
 	  requires __detail::__can_elements_view<_Nm, _Range>
+	  [[nodiscard]]
 	  constexpr auto
 	  operator()(_Range&& __r) const
 	  {
diff --git a/libstdc++-v3/testsuite/20_util/rel_ops.cc b/libstdc++-v3/testsuite/20_util/rel_ops.cc
index 4726462e64e..dd2c14650ae 100644
--- a/libstdc++-v3/testsuite/20_util/rel_ops.cc
+++ b/libstdc++-v3/testsuite/20_util/rel_ops.cc
@@ -17,6 +17,8 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// { dg-options "-Wno-unused-result" }
+
 // 20.2.1 Operators
 
 #include <utility>
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc
index 90574d2a811..d37b1cb4c4e 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::string s("Hello, World!");
-  std::begin(s);
-  std::end(s);
+  (void) std::begin(s);
+  (void) std::end(s);
 }
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/range_access/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/wchar_t/1.cc
index beab3110ca2..56169150089 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/range_access/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/wchar_t/1.cc
@@ -26,7 +26,7 @@ test01()
 {
 #ifdef _GLIBCXX_USE_WCHAR_T
   std::wstring ws(L"Hello, World!");
-  std::begin(ws);
-  std::end(ws);
+  (void) std::begin(ws);
+  (void) std::end(ws);
 #endif
 }
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc
index 856aafde552..4a3595663b8 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc
@@ -25,10 +25,10 @@ void
 test01()
 {
   std::string_view s("Hello, World!");
-  std::begin(s);
-  std::end(s);
-  std::rbegin(s);
-  std::rend(s);
+  (void) std::begin(s);
+  (void) std::end(s);
+  (void) std::rbegin(s);
+  (void) std::rend(s);
 }
 
 void
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc
index c6d83c47bfd..f8ecd1a84cd 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc
@@ -25,10 +25,10 @@ void
 test01()
 {
   std::wstring_view ws(L"Hello, World!");
-  std::begin(ws);
-  std::end(ws);
-  std::rbegin(ws);
-  std::rend(ws);
+  (void) std::begin(ws);
+  (void) std::end(ws);
+  (void) std::rbegin(ws);
+  (void) std::rend(ws);
 }
 
 void
diff --git a/libstdc++-v3/testsuite/23_containers/array/range_access.cc b/libstdc++-v3/testsuite/23_containers/array/range_access.cc
index 38116888a6c..807ccdb2b01 100644
--- a/libstdc++-v3/testsuite/23_containers/array/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::array<int, 3> a{{1, 2, 3}};
-  std::begin(a);
-  std::end(a);
+  (void) std::begin(a);
+  (void) std::end(a);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/deque/range_access.cc b/libstdc++-v3/testsuite/23_containers/deque/range_access.cc
index fed56a48414..990fc0d573b 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::deque<int> d{1, 2, 3};
-  std::begin(d);
-  std::end(d);
+  (void) std::begin(d);
+  (void) std::end(d);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc b/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc
index 0b70ff02131..6398240e126 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::forward_list<int> fl{1, 2, 3};
-  std::begin(fl);
-  std::end(fl);
+  (void) std::begin(fl);
+  (void) std::end(fl);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/list/range_access.cc b/libstdc++-v3/testsuite/23_containers/list/range_access.cc
index de845d446f0..15047ec755d 100644
--- a/libstdc++-v3/testsuite/23_containers/list/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::list<int> l{1, 2, 3};
-  std::begin(l);
-  std::end(l);
+  (void) std::begin(l);
+  (void) std::end(l);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/map/range_access.cc b/libstdc++-v3/testsuite/23_containers/map/range_access.cc
index dc0bdbb9a74..3c6b00128ca 100644
--- a/libstdc++-v3/testsuite/23_containers/map/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::map<int, double> m{{1, 1.0}, {2, 2.0}, {3, 3.0}};
-  std::begin(m);
-  std::end(m);
+  (void) std::begin(m);
+  (void) std::end(m);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc b/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc
index 32ffa3b2651..020a7a9e627 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::multimap<int, double> mm{{1, 1.0}, {2, 2.0}, {3, 3.0}};
-  std::begin(mm);
-  std::end(mm);
+  (void) std::begin(mm);
+  (void) std::end(mm);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc b/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc
index 2d08ba40a59..7e66bfa24aa 100644
--- a/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::multiset<int> ms{1, 2, 3};
-  std::begin(ms);
-  std::end(ms);
+  (void) std::begin(ms);
+  (void) std::end(ms);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/set/range_access.cc b/libstdc++-v3/testsuite/23_containers/set/range_access.cc
index 35703e2a7be..66099b39df4 100644
--- a/libstdc++-v3/testsuite/23_containers/set/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::set<int> s{1, 2, 3};
-  std::begin(s);
-  std::end(s);
+  (void) std::begin(s);
+  (void) std::end(s);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc
index edb06d06894..ad20c1da942 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::unordered_map<int, double> um{{1, 1.0}, {2, 2.0}, {3, 3.0}};
-  std::begin(um);
-  std::end(um);
+  (void) std::begin(um);
+  (void) std::end(um);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc
index e19e825a042..4bb126e34f9 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::unordered_multimap<int, double> umm{{1, 1.0}, {2, 2.0}, {3, 3.0}};
-  std::begin(umm);
-  std::end(umm);
+  (void) std::begin(umm);
+  (void) std::end(umm);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc
index 574012bee32..899b74af35c 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::unordered_multiset<int> ums{1, 2, 3};
-  std::begin(ums);
-  std::end(ums);
+  (void) std::begin(ums);
+  (void) std::end(ums);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc
index 033653a37ec..4f9e8857113 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::unordered_set<int> us{1, 2, 3};
-  std::begin(us);
-  std::end(us);
+  (void) std::begin(us);
+  (void) std::end(us);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/vector/range_access.cc b/libstdc++-v3/testsuite/23_containers/vector/range_access.cc
index a36975cac72..0dd761b71f1 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/range_access.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/range_access.cc
@@ -25,10 +25,10 @@ void
 test01()
 {
   std::vector<double> v{1.0, 2.0, 3.0};
-  std::begin(v);
-  std::end(v);
+  (void) std::begin(v);
+  (void) std::end(v);
 
   std::vector<bool> vb{true, false, true};
-  std::begin(vb);
-  std::end(vb);
+  (void) std::begin(vb);
+  (void) std::end(vb);
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc b/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc
index a43448581f3..40a084b918c 100644
--- a/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc
+++ b/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc
@@ -51,7 +51,7 @@ constexpr bool
 test_X(int i, int j)
 {
   X x1{i}, x2{j};
-  std::ranges::iter_move(&x1); // no-op
+  (void) std::ranges::iter_move(&x1); // no-op
   x1 = std::ranges::iter_move(&x2);
   return x1.value == j &&  x2.value == -1;
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/istream_iterator/sentinel.cc b/libstdc++-v3/testsuite/24_iterators/istream_iterator/sentinel.cc
index 7e1fd173877..f8f16375bf0 100644
--- a/libstdc++-v3/testsuite/24_iterators/istream_iterator/sentinel.cc
+++ b/libstdc++-v3/testsuite/24_iterators/istream_iterator/sentinel.cc
@@ -43,9 +43,9 @@ test02()
   VERIFY( iter != std::default_sentinel );
   VERIFY( std::default_sentinel != iter );
 
-  *iter++;
-  *iter++;
-  *iter++;
+  (void) *iter++;
+  (void) *iter++;
+  (void) *iter++;
   VERIFY( iter == std::default_sentinel );
   VERIFY( std::default_sentinel == iter );
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/sentinel.cc b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/sentinel.cc
index 4961ddaf793..b7cdd44677d 100644
--- a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/sentinel.cc
+++ b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/sentinel.cc
@@ -41,7 +41,7 @@ test02()
   VERIFY( iter != std::default_sentinel );
   VERIFY( std::default_sentinel != iter );
 
-  std::next(iter, 3);
+  (void) std::next(iter, 3);
   VERIFY( iter == std::default_sentinel );
   VERIFY( std::default_sentinel == iter );
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2061.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2061.cc
index 0af4b16b7f4..c9bd3d677e5 100644
--- a/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2061.cc
+++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2061.cc
@@ -23,6 +23,6 @@
 void test01()
 {
   int a[] = { 1, 2, 3, 4 };
-  std::make_move_iterator(a + 4);
-  std::make_move_iterator(a);
+  (void) std::make_move_iterator(a + 4);
+  (void) std::make_move_iterator(a);
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/greedy_ops.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/greedy_ops.cc
index 93b3d7dbcd4..ce50e34a5a6 100644
--- a/libstdc++-v3/testsuite/24_iterators/move_iterator/greedy_ops.cc
+++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/greedy_ops.cc
@@ -1,4 +1,6 @@
 // { dg-do compile { target c++11 } }
+// { dg-options "-Wno-unused-result" }
+
 // Copyright (C) 2010-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
diff --git a/libstdc++-v3/testsuite/24_iterators/normal_iterator/greedy_ops.cc b/libstdc++-v3/testsuite/24_iterators/normal_iterator/greedy_ops.cc
index 557dfacbf24..29ff7266d07 100644
--- a/libstdc++-v3/testsuite/24_iterators/normal_iterator/greedy_ops.cc
+++ b/libstdc++-v3/testsuite/24_iterators/normal_iterator/greedy_ops.cc
@@ -1,4 +1,6 @@
 // { dg-do compile }
+// { dg-options "-Wno-unused-result" }
+
 // Copyright (C) 2010-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -33,7 +35,7 @@ void test01()
 				       greedy_ops::C> iterator_type;
 
   iterator_type it(0);
-  
+
   it == it;
   it != it;
   it < it;
@@ -45,8 +47,8 @@ void test01()
   1 + it;
 }
 
-int main() 
-{ 
+int main()
+{
   test01();
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc b/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
index 1d421bbcb2d..cafafc4b651 100644
--- a/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
+++ b/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
@@ -37,6 +37,6 @@ void
 test02()
 {
   const Y array[1] = { };
-  std::prev(array + 1);
+  (void) std::prev(array + 1);
   // { dg-error "forward_iterator" "" { target *-*-* } 223 }
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator/2.cc b/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator/2.cc
index 847f4352739..a962cd58236 100644
--- a/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator/2.cc
+++ b/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator/2.cc
@@ -45,7 +45,7 @@ void test02(void)
   VERIFY( !ostrb_it01.failed() );
   ostrb_it01 = 'a';
   VERIFY( !ostrb_it01.failed() );
-  *ostrb_it01;
+  (void) *ostrb_it01;
   VERIFY( !ostrb_it01.failed() );
 
   costreambuf_iter ostrb_it02(0);
@@ -53,11 +53,11 @@ void test02(void)
   ostrb_it02++;
   ++ostrb_it02;
   VERIFY( ostrb_it02.failed() );
-  *ostrb_it02;
+  (void) *ostrb_it02;
   VERIFY( ostrb_it02.failed() );
   ostrb_it02 = 'a';
   VERIFY( ostrb_it02.failed() );
-  
+
   // charT operator*() const
   // ostreambuf_iterator& operator++();
   // ostreambuf_iterator& operator++(int);
diff --git a/libstdc++-v3/testsuite/24_iterators/range_access/range_access.cc b/libstdc++-v3/testsuite/24_iterators/range_access/range_access.cc
index b0b379c6ea5..e679f24e75b 100644
--- a/libstdc++-v3/testsuite/24_iterators/range_access/range_access.cc
+++ b/libstdc++-v3/testsuite/24_iterators/range_access/range_access.cc
@@ -25,8 +25,8 @@ void
 test01()
 {
   int arr[3] = {1, 2, 3};
-  std::begin(arr);
-  std::end(arr);
+  (void) std::begin(arr);
+  (void) std::end(arr);
 
   static_assert( noexcept(std::begin(arr)), "LWG 2280" );
   static_assert( noexcept(std::end(arr)), "LWG 2280" );
diff --git a/libstdc++-v3/testsuite/24_iterators/range_operations/100768.cc b/libstdc++-v3/testsuite/24_iterators/range_operations/100768.cc
index bbcfcece5ff..d4deedd82f6 100644
--- a/libstdc++-v3/testsuite/24_iterators/range_operations/100768.cc
+++ b/libstdc++-v3/testsuite/24_iterators/range_operations/100768.cc
@@ -114,15 +114,15 @@ test01()
   // deleted overloads in namespace ns3 (because it is an associated namespace
   // and those functions are exact matches for the arguments).
   using namespace std::ranges;
-  advance(iter, 1);
-  advance(iter, 3, sentinel);
-  distance(iter, sentinel);
-  distance(range);
-  next(iter);
-  next(iter, -1);
-  next(iter, sentinel);
-  next(iter, 5, sentinel);
-  prev(iter);
-  prev(iter, 0);
-  prev(iter, 0, sentinel);
+  (void) advance(iter, 1);
+  (void) advance(iter, 3, sentinel);
+  (void) distance(iter, sentinel);
+  (void) distance(range);
+  (void) next(iter);
+  (void) next(iter, -1);
+  (void) next(iter, sentinel);
+  (void) next(iter, 5, sentinel);
+  (void) prev(iter);
+  (void) prev(iter, 0);
+  (void) prev(iter, 0, sentinel);
 }
diff --git a/libstdc++-v3/testsuite/24_iterators/reverse_iterator/2.cc b/libstdc++-v3/testsuite/24_iterators/reverse_iterator/2.cc
index 633c1426b96..bd8b20d877d 100644
--- a/libstdc++-v3/testsuite/24_iterators/reverse_iterator/2.cc
+++ b/libstdc++-v3/testsuite/24_iterators/reverse_iterator/2.cc
@@ -17,6 +17,8 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// { dg-options "-Wno-unused-result" }
+
 // 24.4.1.2 Reverse iterators
 
 #include <iterator>
diff --git a/libstdc++-v3/testsuite/24_iterators/reverse_iterator/greedy_ops.cc b/libstdc++-v3/testsuite/24_iterators/reverse_iterator/greedy_ops.cc
index 012f0082751..e5e6dd25027 100644
--- a/libstdc++-v3/testsuite/24_iterators/reverse_iterator/greedy_ops.cc
+++ b/libstdc++-v3/testsuite/24_iterators/reverse_iterator/greedy_ops.cc
@@ -1,4 +1,6 @@
 // { dg-do compile }
+// { dg-options "-Wno-unused-result" }
+
 // Copyright (C) 2010-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc
index a7ce1332117..cf5418a61d1 100644
--- a/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc
+++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc
@@ -27,9 +27,9 @@ void
 test01()
 {
   std::valarray<double> va{1.0, 2.0, 3.0};
-  std::cbegin(va);
-  std::cend(va);
+  (void) std::cbegin(va);
+  (void) std::cend(va);
   const auto& cva = va;
-  std::cbegin(cva);
-  std::cend(cva);
+  (void) std::cbegin(cva);
+  (void) std::cend(cva);
 }
diff --git a/libstdc++-v3/testsuite/28_regex/range_access.cc b/libstdc++-v3/testsuite/28_regex/range_access.cc
index 46ef3c64391..6baefbfb673 100644
--- a/libstdc++-v3/testsuite/28_regex/range_access.cc
+++ b/libstdc++-v3/testsuite/28_regex/range_access.cc
@@ -26,6 +26,6 @@ void
 test01()
 {
   std::smatch sm;
-  std::begin(sm);
-  std::end(sm);
+  (void) std::begin(sm);
+  (void) std::end(sm);
 }
diff --git a/libstdc++-v3/testsuite/experimental/string_view/range_access/char/1.cc b/libstdc++-v3/testsuite/experimental/string_view/range_access/char/1.cc
index c750430d6af..1c456920e5b 100644
--- a/libstdc++-v3/testsuite/experimental/string_view/range_access/char/1.cc
+++ b/libstdc++-v3/testsuite/experimental/string_view/range_access/char/1.cc
@@ -25,6 +25,6 @@ void
 test01()
 {
   std::experimental::string_view s("Hello, World!");
-  std::begin(s);
-  std::end(s);
+  (void) std::begin(s);
+  (void) std::end(s);
 }
diff --git a/libstdc++-v3/testsuite/experimental/string_view/range_access/wchar_t/1.cc b/libstdc++-v3/testsuite/experimental/string_view/range_access/wchar_t/1.cc
index 1dd926333c3..f19e455a606 100644
--- a/libstdc++-v3/testsuite/experimental/string_view/range_access/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/experimental/string_view/range_access/wchar_t/1.cc
@@ -26,7 +26,7 @@ test01()
 {
 #ifdef _GLIBCXX_USE_WCHAR_T
   std::experimental::wstring_view ws(L"Hello, World!");
-  std::begin(ws);
-  std::end(ws);
+  (void) std::begin(ws);
+  (void) std::end(ws);
 #endif
 }
diff --git a/libstdc++-v3/testsuite/ext/vstring/range_access.cc b/libstdc++-v3/testsuite/ext/vstring/range_access.cc
index 8219eeabed1..7b381ffd956 100644
--- a/libstdc++-v3/testsuite/ext/vstring/range_access.cc
+++ b/libstdc++-v3/testsuite/ext/vstring/range_access.cc
@@ -25,12 +25,12 @@ void
 test01()
 {
   __gnu_cxx::__vstring s("Hello, World!");
-  std::begin(s);
-  std::end(s);
+  (void) std::begin(s);
+  (void) std::end(s);
 
 #ifdef _GLIBCXX_USE_WCHAR_T
   __gnu_cxx::__wvstring ws(L"Hello, World!");
-  std::begin(ws);
-  std::end(ws);
+  (void) std::begin(ws);
+  (void) std::end(ws);
 #endif
 }
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc
index 55f74824737..d79d451478d 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc
@@ -62,7 +62,7 @@ test03()
   int x[] = {0,1,2,3,4,5};
   auto is_odd = [] (int i) { return i%2 == 1; };
   auto v = x | views::filter(is_odd) | views::take(3);
-  ranges::begin(v);
+  (void) ranges::begin(v);
   using R = decltype(v);
   static_assert(ranges::view<R>);
   static_assert(!ranges::sized_range<R>);
diff --git a/libstdc++-v3/testsuite/std/ranges/p2259.cc b/libstdc++-v3/testsuite/std/ranges/p2259.cc
index 0ec7e21f657..89234e246a0 100644
--- a/libstdc++-v3/testsuite/std/ranges/p2259.cc
+++ b/libstdc++-v3/testsuite/std/ranges/p2259.cc
@@ -64,7 +64,7 @@ test01()
 
   // Verify the changes to common_iterator.
   only_cxx20_input_range auto v6 = v0 | views::common;
-  *(v6.begin()++);
+  (void) *(v6.begin()++);
 
   // Verify the changes to iota_view.
   only_cxx20_input_range auto v8 = ranges::iota_view{v0.begin()};
@@ -77,7 +77,7 @@ test01()
   static_assert(std::contiguous_iterator<decltype(i10)>);
   static_assert(std::same_as<std::iterator_traits<decltype(i10)>::iterator_category,
 			     std::random_access_iterator_tag>);
-  i10.operator->();
+  (void) i10.operator->();
   __iter_without_category auto i11 = std::counted_iterator{v0.begin(), 5};
 }
 
