public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2730] libstdc++: Add [[nodiscard]] to sequence containers
@ 2021-08-04 11:55 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-08-04 11:55 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:0d04fe49239d91787850036599164788f1c87785

commit r12-2730-g0d04fe49239d91787850036599164788f1c87785
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 3 20:50:52 2021 +0100

    libstdc++: Add [[nodiscard]] to sequence containers
    
    ... and container adaptors.
    
    This adds the [[nodiscard]] attribute to functions with no side-effects
    for the sequence containers and their iterators, and the debug versions
    of those containers, and the container adaptors,
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/forward_list.h: Add [[nodiscard]] to functions
            with no side-effects.
            * include/bits/stl_bvector.h: Likewise.
            * include/bits/stl_deque.h: Likewise.
            * include/bits/stl_list.h: Likewise.
            * include/bits/stl_queue.h: Likewise.
            * include/bits/stl_stack.h: Likewise.
            * include/bits/stl_vector.h: Likewise.
            * include/debug/deque: Likewise.
            * include/debug/forward_list: Likewise.
            * include/debug/list: Likewise.
            * include/debug/safe_iterator.h: Likewise.
            * include/debug/vector: Likewise.
            * include/std/array: Likewise.
            * testsuite/23_containers/array/creation/3_neg.cc: Use
            -Wno-unused-result.
            * testsuite/23_containers/array/debug/back1_neg.cc: Cast result
            to void.
            * testsuite/23_containers/array/debug/back2_neg.cc: Likewise.
            * testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
            * testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
            * testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc:
            Likewise.
            * testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc:
            Likewise.
            * testsuite/23_containers/array/tuple_interface/get_neg.cc:
            Adjust dg-error line numbers.
            * testsuite/23_containers/deque/cons/clear_allocator.cc: Cast
            result to void.
            * testsuite/23_containers/deque/debug/invalidation/4.cc:
            Likewise.
            * testsuite/23_containers/deque/types/1.cc: Use
            -Wno-unused-result.
            * testsuite/23_containers/list/types/1.cc: Cast result to void.
            * testsuite/23_containers/priority_queue/members/7161.cc:
            Likewise.
            * testsuite/23_containers/queue/members/7157.cc: Likewise.
            * testsuite/23_containers/vector/59829.cc: Likewise.
            * testsuite/23_containers/vector/ext_pointer/types/1.cc:
            Likewise.
            * testsuite/23_containers/vector/ext_pointer/types/2.cc:
            Likewise.
            * testsuite/23_containers/vector/types/1.cc: Use
            -Wno-unused-result.

Diff:
---
 libstdc++-v3/include/bits/forward_list.h           | 30 ++++++++++++-
 libstdc++-v3/include/bits/stl_bvector.h            | 41 ++++++++++++++++++
 libstdc++-v3/include/bits/stl_deque.h              | 49 ++++++++++++++++++++++
 libstdc++-v3/include/bits/stl_list.h               | 33 +++++++++++++++
 libstdc++-v3/include/bits/stl_queue.h              | 17 ++++++++
 libstdc++-v3/include/bits/stl_stack.h              | 10 +++++
 libstdc++-v3/include/bits/stl_vector.h             | 23 ++++++++++
 libstdc++-v3/include/debug/deque                   | 18 ++++++++
 libstdc++-v3/include/debug/forward_list            | 11 +++++
 libstdc++-v3/include/debug/list                    | 16 +++++++
 libstdc++-v3/include/debug/safe_iterator.h         | 22 ++++++++++
 libstdc++-v3/include/debug/vector                  | 19 +++++++++
 libstdc++-v3/include/std/array                     | 38 ++++++++++++++++-
 .../23_containers/array/creation/3_neg.cc          |  2 +-
 .../23_containers/array/debug/back1_neg.cc         |  2 +-
 .../23_containers/array/debug/back2_neg.cc         |  2 +-
 .../23_containers/array/debug/front1_neg.cc        |  2 +-
 .../23_containers/array/debug/front2_neg.cc        |  2 +-
 .../array/debug/square_brackets_operator1_neg.cc   |  2 +-
 .../array/debug/square_brackets_operator2_neg.cc   |  2 +-
 .../23_containers/array/tuple_interface/get_neg.cc |  6 +--
 .../23_containers/deque/cons/clear_allocator.cc    | 24 +++++------
 .../23_containers/deque/debug/invalidation/4.cc    |  2 +-
 .../testsuite/23_containers/deque/types/1.cc       |  1 +
 .../testsuite/23_containers/list/types/1.cc        |  2 +-
 .../23_containers/priority_queue/members/7161.cc   |  2 +-
 .../testsuite/23_containers/queue/members/7157.cc  |  2 +-
 .../testsuite/23_containers/vector/59829.cc        |  2 +-
 .../23_containers/vector/ext_pointer/types/1.cc    |  8 ++--
 .../23_containers/vector/ext_pointer/types/2.cc    |  8 ++--
 .../testsuite/23_containers/vector/types/1.cc      |  1 +
 31 files changed, 362 insertions(+), 37 deletions(-)

diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h
index e61746848f6..ab6d9389194 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -150,10 +150,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _Fwd_list_iterator(_Fwd_list_node_base* __n) noexcept
       : _M_node(__n) { }
 
+      [[__nodiscard__]]
       reference
       operator*() const noexcept
       { return *static_cast<_Node*>(this->_M_node)->_M_valptr(); }
 
+      [[__nodiscard__]]
       pointer
       operator->() const noexcept
       { return static_cast<_Node*>(this->_M_node)->_M_valptr(); }
@@ -176,6 +178,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /**
        *  @brief  Forward list iterator equality comparison.
        */
+      [[__nodiscard__]]
       friend bool
       operator==(const _Self& __x, const _Self& __y) noexcept
       { return __x._M_node == __y._M_node; }
@@ -184,6 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /**
        *  @brief  Forward list iterator inequality comparison.
        */
+      [[__nodiscard__]]
       friend bool
       operator!=(const _Self& __x, const _Self& __y) noexcept
       { return __x._M_node != __y._M_node; }
@@ -229,10 +233,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _Fwd_list_const_iterator(const iterator& __iter) noexcept
       : _M_node(__iter._M_node) { }
 
+      [[__nodiscard__]]
       reference
       operator*() const noexcept
       { return *static_cast<_Node*>(this->_M_node)->_M_valptr(); }
 
+      [[__nodiscard__]]
       pointer
       operator->() const noexcept
       { return static_cast<_Node*>(this->_M_node)->_M_valptr(); }
@@ -255,6 +261,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /**
        *  @brief  Forward list const_iterator equality comparison.
        */
+      [[__nodiscard__]]
       friend bool
       operator==(const _Self& __x, const _Self& __y) noexcept
       { return __x._M_node == __y._M_node; }
@@ -263,6 +270,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /**
        *  @brief  Forward list const_iterator inequality comparison.
        */
+      [[__nodiscard__]]
       friend bool
       operator!=(const _Self& __x, const _Self& __y) noexcept
       { return __x._M_node != __y._M_node; }
@@ -698,6 +706,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write iterator that points before the first element
        *  in the %forward_list.  Iteration is done in ordinary element order.
        */
+      [[__nodiscard__]]
       iterator
       before_begin() noexcept
       { return iterator(&this->_M_impl._M_head); }
@@ -707,6 +716,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  first element in the %forward_list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       before_begin() const noexcept
       { return const_iterator(&this->_M_impl._M_head); }
@@ -715,6 +725,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write iterator that points to the first element
        *  in the %forward_list.  Iteration is done in ordinary element order.
        */
+      [[__nodiscard__]]
       iterator
       begin() noexcept
       { return iterator(this->_M_impl._M_head._M_next); }
@@ -724,6 +735,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  element in the %forward_list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       begin() const noexcept
       { return const_iterator(this->_M_impl._M_head._M_next); }
@@ -733,6 +745,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  element in the %forward_list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       iterator
       end() noexcept
       { return iterator(nullptr); }
@@ -742,6 +755,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  element in the %forward_list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       end() const noexcept
       { return const_iterator(nullptr); }
@@ -751,6 +765,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  first element in the %forward_list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(this->_M_impl._M_head._M_next); }
@@ -760,6 +775,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  first element in the %forward_list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cbefore_begin() const noexcept
       { return const_iterator(&this->_M_impl._M_head); }
@@ -769,6 +785,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  the last element in the %forward_list.  Iteration is done in
        *  ordinary element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return const_iterator(nullptr); }
@@ -777,13 +794,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns true if the %forward_list is empty.  (Thus begin() would
        *  equal end().)
        */
-      _GLIBCXX_NODISCARD bool
+      [[__nodiscard__]]
+      bool
       empty() const noexcept
       { return this->_M_impl._M_head._M_next == nullptr; }
 
       /**
        *  Returns the largest possible number of elements of %forward_list.
        */
+      [[__nodiscard__]]
       size_type
       max_size() const noexcept
       { return _Node_alloc_traits::max_size(this->_M_get_Node_allocator()); }
@@ -794,6 +813,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write reference to the data at the first
        *  element of the %forward_list.
        */
+      [[__nodiscard__]]
       reference
       front()
       {
@@ -805,6 +825,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %forward_list.
        */
+      [[__nodiscard__]]
       const_reference
       front() const
       {
@@ -1425,6 +1446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  if corresponding elements compare equal.
    */
   template<typename _Tp, typename _Alloc>
+    [[__nodiscard__]]
     bool
     operator==(const forward_list<_Tp, _Alloc>& __lx,
 	       const forward_list<_Tp, _Alloc>& __ly);
@@ -1442,6 +1464,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  `<` and `>=` etc.
   */
   template<typename _Tp, typename _Alloc>
+    [[nodiscard]]
     inline __detail::__synth3way_t<_Tp>
     operator<=>(const forward_list<_Tp, _Alloc>& __x,
 		const forward_list<_Tp, _Alloc>& __y)
@@ -1464,6 +1487,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  See std::lexicographical_compare() for how the determination is made.
    */
   template<typename _Tp, typename _Alloc>
+    [[__nodiscard__]]
     inline bool
     operator<(const forward_list<_Tp, _Alloc>& __lx,
 	      const forward_list<_Tp, _Alloc>& __ly)
@@ -1472,6 +1496,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   /// Based on operator==
   template<typename _Tp, typename _Alloc>
+    [[__nodiscard__]]
     inline bool
     operator!=(const forward_list<_Tp, _Alloc>& __lx,
 	       const forward_list<_Tp, _Alloc>& __ly)
@@ -1479,6 +1504,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    [[__nodiscard__]]
     inline bool
     operator>(const forward_list<_Tp, _Alloc>& __lx,
 	      const forward_list<_Tp, _Alloc>& __ly)
@@ -1486,6 +1512,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    [[__nodiscard__]]
     inline bool
     operator>=(const forward_list<_Tp, _Alloc>& __lx,
 	       const forward_list<_Tp, _Alloc>& __ly)
@@ -1493,6 +1520,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    [[__nodiscard__]]
     inline bool
     operator<=(const forward_list<_Tp, _Alloc>& __lx,
 	       const forward_list<_Tp, _Alloc>& __ly)
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index fadb6615102..a954890ff20 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -83,6 +83,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     _Bit_reference(const _Bit_reference&) = default;
 #endif
 
+    _GLIBCXX_NODISCARD
     operator bool() const _GLIBCXX_NOEXCEPT
     { return !!(*_M_p & _M_mask); }
 
@@ -100,10 +101,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT
     { return *this = bool(__x); }
 
+    _GLIBCXX_NODISCARD
     bool
     operator==(const _Bit_reference& __x) const
     { return bool(*this) == bool(__x); }
 
+    _GLIBCXX_NODISCARD
     bool
     operator<(const _Bit_reference& __x) const
     { return !bool(*this) && bool(__x); }
@@ -182,11 +185,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _M_offset = static_cast<unsigned int>(__n);
     }
 
+    _GLIBCXX_NODISCARD
     friend _GLIBCXX20_CONSTEXPR bool
     operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     { return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; }
 
 #if __cpp_lib_three_way_comparison
+    [[nodiscard]]
     friend constexpr strong_ordering
     operator<=>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     noexcept
@@ -196,6 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return __x._M_offset <=> __y._M_offset;
     }
 #else
+    _GLIBCXX_NODISCARD
     friend bool
     operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     {
@@ -203,18 +209,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	    || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
     }
 
+    _GLIBCXX_NODISCARD
     friend bool
     operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     { return !(__x == __y); }
 
+    _GLIBCXX_NODISCARD
     friend bool
     operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     { return __y < __x; }
 
+    _GLIBCXX_NODISCARD
     friend bool
     operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     { return !(__y < __x); }
 
+    _GLIBCXX_NODISCARD
     friend bool
     operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     { return !(__x < __y); }
@@ -247,6 +257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     _M_const_cast() const
     { return *this; }
 
+    _GLIBCXX_NODISCARD
     reference
     operator*() const
     { return reference(_M_p, 1UL << _M_offset); }
@@ -295,10 +306,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return *this;
     }
 
+    _GLIBCXX_NODISCARD
     reference
     operator[](difference_type __i) const
     { return *(*this + __i); }
 
+    _GLIBCXX_NODISCARD
     friend iterator
     operator+(const iterator& __x, difference_type __n)
     {
@@ -307,10 +320,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return __tmp;
     }
 
+    _GLIBCXX_NODISCARD
     friend iterator
     operator+(difference_type __n, const iterator& __x)
     { return __x + __n; }
 
+    _GLIBCXX_NODISCARD
     friend iterator
     operator-(const iterator& __x, difference_type __n)
     {
@@ -343,6 +358,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     _M_const_cast() const
     { return _Bit_iterator(_M_p, _M_offset); }
 
+    _GLIBCXX_NODISCARD
     const_reference
     operator*() const
     { return _Bit_reference(_M_p, 1UL << _M_offset); }
@@ -391,10 +407,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return *this;
     }
 
+    _GLIBCXX_NODISCARD
     const_reference
     operator[](difference_type __i) const
     { return *(*this + __i); }
 
+    _GLIBCXX_NODISCARD
     friend const_iterator
     operator+(const const_iterator& __x, difference_type __n)
     {
@@ -403,6 +421,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return __tmp;
     }
 
+    _GLIBCXX_NODISCARD
     friend const_iterator
     operator-(const const_iterator& __x, difference_type __n)
     {
@@ -411,6 +430,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return __tmp;
     }
 
+    _GLIBCXX_NODISCARD
     friend const_iterator
     operator+(difference_type __n, const const_iterator& __x)
     { return __x + __n; }
@@ -827,60 +847,74 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
 #endif
 
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return iterator(this->_M_impl._M_start._M_p, 0); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return const_iterator(this->_M_impl._M_start._M_p, 0); }
 
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_finish; }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_finish; }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(begin()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(begin()); }
 
 #if __cplusplus >= 201103L
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(this->_M_impl._M_start._M_p, 0); }
 
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return this->_M_impl._M_finish; }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
 #endif
 
+      _GLIBCXX_NODISCARD
       size_type
       size() const _GLIBCXX_NOEXCEPT
       { return size_type(end() - begin()); }
 
+      _GLIBCXX_NODISCARD
       size_type
       max_size() const _GLIBCXX_NOEXCEPT
       {
@@ -893,6 +927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 		? __asize * int(_S_word_bit) : __isize);
       }
 
+      _GLIBCXX_NODISCARD
       size_type
       capacity() const _GLIBCXX_NOEXCEPT
       { return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
@@ -902,10 +937,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       empty() const _GLIBCXX_NOEXCEPT
       { return begin() == end(); }
 
+      _GLIBCXX_NODISCARD
       reference
       operator[](size_type __n)
       { return begin()[__n]; }
 
+      _GLIBCXX_NODISCARD
       const_reference
       operator[](size_type __n) const
       { return begin()[__n]; }
@@ -939,18 +976,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  _M_reallocate(__n);
       }
 
+      _GLIBCXX_NODISCARD
       reference
       front()
       { return *begin(); }
 
+      _GLIBCXX_NODISCARD
       const_reference
       front() const
       { return *begin(); }
 
+      _GLIBCXX_NODISCARD
       reference
       back()
       { return *(end() - 1); }
 
+      _GLIBCXX_NODISCARD
       const_reference
       back() const
       { return *(end() - 1); }
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index 20c73b4fc3c..6095498d440 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -176,10 +176,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _M_const_cast() const _GLIBCXX_NOEXCEPT
       { return iterator(_M_cur, _M_node); }
 
+      _GLIBCXX_NODISCARD
       reference
       operator*() const _GLIBCXX_NOEXCEPT
       { return *_M_cur; }
 
+      _GLIBCXX_NODISCARD
       pointer
       operator->() const _GLIBCXX_NOEXCEPT
       { return _M_cur; }
@@ -247,6 +249,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
       { return *this += -__n; }
 
+      _GLIBCXX_NODISCARD
       reference
       operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
       { return *(*this + __n); }
@@ -264,6 +267,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	_M_last = _M_first + difference_type(_S_buffer_size());
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return __x._M_cur == __y._M_cur; }
@@ -272,6 +276,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       // order to avoid ambiguous overload resolution when std::rel_ops
       // operators are in scope (for additional details, see libstdc++/3628)
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator==(const _Self& __x,
 		   const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
@@ -279,6 +284,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	{ return __x._M_cur == __y._M_cur; }
 
 #if __cpp_lib_three_way_comparison
+      [[nodiscard]]
       friend strong_ordering
       operator<=>(const _Self& __x, const _Self& __y) noexcept
       {
@@ -287,17 +293,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	return __x._M_cur <=> __y._M_cur;
       }
 #else
+      _GLIBCXX_NODISCARD
       friend bool
       operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return !(__x == __y); }
 
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator!=(const _Self& __x,
 		   const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
 	_GLIBCXX_NOEXCEPT
 	{ return !(__x == __y); }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator<(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       {
@@ -306,6 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       }
 
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator<(const _Self& __x,
 		  const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
@@ -315,33 +325,39 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	    ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
 	}
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator>(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return __y < __x; }
 
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator>(const _Self& __x,
 		  const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
 	_GLIBCXX_NOEXCEPT
 	{ return __y < __x; }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator<=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return !(__y < __x); }
 
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator<=(const _Self& __x,
 		   const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
 	_GLIBCXX_NOEXCEPT
 	{ return !(__y < __x); }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator>=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return !(__x < __y); }
 
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator>=(const _Self& __x,
 		   const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
@@ -349,6 +365,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	{ return !(__x < __y); }
 #endif // three-way comparison
 
+      _GLIBCXX_NODISCARD
       friend difference_type
       operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       {
@@ -363,6 +380,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       // operators but also operator- must accept mixed iterator/const_iterator
       // parameters.
       template<typename _RefR, typename _PtrR>
+	_GLIBCXX_NODISCARD
 	friend difference_type
 	operator-(const _Self& __x,
 		  const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
@@ -373,6 +391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	    + (__y._M_last - __y._M_cur);
 	}
 
+      _GLIBCXX_NODISCARD
       friend _Self
       operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -381,6 +400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	return __tmp;
       }
 
+      _GLIBCXX_NODISCARD
       friend _Self
       operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -389,6 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	return __tmp;
       }
 
+      _GLIBCXX_NODISCARD
       friend _Self
       operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT
       { return __x + __n; }
@@ -1114,6 +1135,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 #endif
 
       /// Get a copy of the memory allocation object.
+      _GLIBCXX_NODISCARD
       allocator_type
       get_allocator() const _GLIBCXX_NOEXCEPT
       { return _Base::get_allocator(); }
@@ -1123,6 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write iterator that points to the first element in the
        *  %deque.  Iteration is done in ordinary element order.
        */
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_start; }
@@ -1131,6 +1154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) iterator that points to the first
        *  element in the %deque.  Iteration is done in ordinary element order.
        */
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_start; }
@@ -1140,6 +1164,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  element in the %deque.  Iteration is done in ordinary
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_finish; }
@@ -1149,6 +1174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  the last element in the %deque.  Iteration is done in
        *  ordinary element order.
        */
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_finish; }
@@ -1158,6 +1184,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  last element in the %deque.  Iteration is done in reverse
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(this->_M_impl._M_finish); }
@@ -1167,6 +1194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to the last element in the %deque.  Iteration is done in
        *  reverse element order.
        */
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(this->_M_impl._M_finish); }
@@ -1176,6 +1204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  before the first element in the %deque.  Iteration is done
        *  in reverse element order.
        */
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(this->_M_impl._M_start); }
@@ -1185,6 +1214,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to one before the first element in the %deque.  Iteration is
        *  done in reverse element order.
        */
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(this->_M_impl._M_start); }
@@ -1194,6 +1224,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) iterator that points to the first
        *  element in the %deque.  Iteration is done in ordinary element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return this->_M_impl._M_start; }
@@ -1203,6 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  the last element in the %deque.  Iteration is done in
        *  ordinary element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return this->_M_impl._M_finish; }
@@ -1212,6 +1244,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to the last element in the %deque.  Iteration is done in
        *  reverse element order.
        */
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(this->_M_impl._M_finish); }
@@ -1221,6 +1254,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to one before the first element in the %deque.  Iteration is
        *  done in reverse element order.
        */
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(this->_M_impl._M_start); }
@@ -1228,11 +1262,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
       // [23.2.1.2] capacity
       /**  Returns the number of elements in the %deque.  */
+      _GLIBCXX_NODISCARD
       size_type
       size() const _GLIBCXX_NOEXCEPT
       { return this->_M_impl._M_finish - this->_M_impl._M_start; }
 
       /**  Returns the size() of the largest possible %deque.  */
+      _GLIBCXX_NODISCARD
       size_type
       max_size() const _GLIBCXX_NOEXCEPT
       { return _S_max_size(_M_get_Tp_allocator()); }
@@ -1322,6 +1358,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  out_of_range lookups are not defined. (For checked lookups
        *  see at().)
        */
+      _GLIBCXX_NODISCARD
       reference
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -1340,6 +1377,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  out_of_range lookups are not defined. (For checked lookups
        *  see at().)
        */
+      _GLIBCXX_NODISCARD
       const_reference
       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
       {
@@ -1400,6 +1438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write reference to the data at the first
        *  element of the %deque.
        */
+      _GLIBCXX_NODISCARD
       reference
       front() _GLIBCXX_NOEXCEPT
       {
@@ -1411,6 +1450,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %deque.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       front() const _GLIBCXX_NOEXCEPT
       {
@@ -1422,6 +1462,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write reference to the data at the last element of the
        *  %deque.
        */
+      _GLIBCXX_NODISCARD
       reference
       back() _GLIBCXX_NOEXCEPT
       {
@@ -1435,6 +1476,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) reference to the data at the last
        *  element of the %deque.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       back() const _GLIBCXX_NOEXCEPT
       {
@@ -2242,6 +2284,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  and if corresponding elements compare equal.
   */
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     { return __x.size() == __y.size()
@@ -2260,6 +2303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  `<` and `>=` etc.
   */
   template<typename _Tp, typename _Alloc>
+    [[nodiscard]]
     inline __detail::__synth3way_t<_Tp>
     operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     {
@@ -2280,6 +2324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  See std::lexicographical_compare() for how the determination is made.
   */
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     { return std::lexicographical_compare(__x.begin(), __x.end(),
@@ -2287,24 +2332,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   /// Based on operator==
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator!=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     { return !(__x == __y); }
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     { return __y < __x; }
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     { return !(__y < __x); }
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
     { return !(__x < __y); }
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index dbe05a9834b..9ae640ee692 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -205,10 +205,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { return *this; }
 
       // Must downcast from _List_node_base to _List_node to get to value.
+      _GLIBCXX_NODISCARD
       reference
       operator*() const _GLIBCXX_NOEXCEPT
       { return *static_cast<_Node*>(_M_node)->_M_valptr(); }
 
+      _GLIBCXX_NODISCARD
       pointer
       operator->() const _GLIBCXX_NOEXCEPT
       { return static_cast<_Node*>(_M_node)->_M_valptr(); }
@@ -243,11 +245,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	return __tmp;
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return __x._M_node == __y._M_node; }
 
 #if __cpp_impl_three_way_comparison < 201907L
+      _GLIBCXX_NODISCARD
       friend bool
       operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return __x._M_node != __y._M_node; }
@@ -291,10 +295,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { return iterator(const_cast<__detail::_List_node_base*>(_M_node)); }
 
       // Must downcast from List_node_base to _List_node to get to value.
+      _GLIBCXX_NODISCARD
       reference
       operator*() const _GLIBCXX_NOEXCEPT
       { return *static_cast<_Node*>(_M_node)->_M_valptr(); }
 
+      _GLIBCXX_NODISCARD
       pointer
       operator->() const _GLIBCXX_NOEXCEPT
       { return static_cast<_Node*>(_M_node)->_M_valptr(); }
@@ -329,11 +335,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	return __tmp;
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return __x._M_node == __y._M_node; }
 
 #if __cpp_impl_three_way_comparison < 201907L
+      _GLIBCXX_NODISCARD
       friend bool
       operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       { return __x._M_node != __y._M_node; }
@@ -941,6 +949,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  Returns a read/write iterator that points to the first element in the
        *  %list.  Iteration is done in ordinary element order.
        */
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return iterator(this->_M_impl._M_node._M_next); }
@@ -950,6 +959,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  first element in the %list.  Iteration is done in ordinary
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return const_iterator(this->_M_impl._M_node._M_next); }
@@ -959,6 +969,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  element in the %list.  Iteration is done in ordinary element
        *  order.
        */
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return iterator(&this->_M_impl._M_node); }
@@ -968,6 +979,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  the last element in the %list.  Iteration is done in ordinary
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return const_iterator(&this->_M_impl._M_node); }
@@ -977,6 +989,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  element in the %list.  Iteration is done in reverse element
        *  order.
        */
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(end()); }
@@ -986,6 +999,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  the last element in the %list.  Iteration is done in reverse
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(end()); }
@@ -995,6 +1009,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  before the first element in the %list.  Iteration is done in
        *  reverse element order.
        */
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(begin()); }
@@ -1004,6 +1019,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  before the first element in the %list.  Iteration is done in reverse
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(begin()); }
@@ -1014,6 +1030,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  first element in the %list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(this->_M_impl._M_node._M_next); }
@@ -1023,6 +1040,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  the last element in the %list.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return const_iterator(&this->_M_impl._M_node); }
@@ -1032,6 +1050,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  the last element in the %list.  Iteration is done in reverse
        *  element order.
        */
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
@@ -1041,6 +1060,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  before the first element in the %list.  Iteration is done in reverse
        *  element order.
        */
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
@@ -1056,11 +1076,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
 
       /**  Returns the number of elements in the %list.  */
+      _GLIBCXX_NODISCARD
       size_type
       size() const _GLIBCXX_NOEXCEPT
       { return _M_node_count(); }
 
       /**  Returns the size() of the largest possible %list.  */
+      _GLIBCXX_NODISCARD
       size_type
       max_size() const _GLIBCXX_NOEXCEPT
       { return _Node_alloc_traits::max_size(_M_get_Node_allocator()); }
@@ -1110,6 +1132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  Returns a read/write reference to the data at the first
        *  element of the %list.
        */
+      _GLIBCXX_NODISCARD
       reference
       front() _GLIBCXX_NOEXCEPT
       { return *begin(); }
@@ -1118,6 +1141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %list.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       front() const _GLIBCXX_NOEXCEPT
       { return *begin(); }
@@ -1126,6 +1150,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  Returns a read/write reference to the data at the last element
        *  of the %list.
        */
+      _GLIBCXX_NODISCARD
       reference
       back() _GLIBCXX_NOEXCEPT
       {
@@ -1138,6 +1163,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *  Returns a read-only (constant) reference to the data at the last
        *  element of the %list.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       back() const _GLIBCXX_NOEXCEPT
       {
@@ -1991,6 +2017,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
    *  equal, and if corresponding elements compare equal.
   */
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     {
@@ -2026,6 +2053,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
    *  `<` and `>=` etc.
   */
   template<typename _Tp, typename _Alloc>
+    [[nodiscard]]
     inline __detail::__synth3way_t<_Tp>
     operator<=>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     {
@@ -2046,6 +2074,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
    *  See std::lexicographical_compare() for how the determination is made.
   */
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     { return std::lexicographical_compare(__x.begin(), __x.end(),
@@ -2053,24 +2082,28 @@ _GLIBCXX_END_NAMESPACE_CXX11
 
   /// Based on operator==
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     { return !(__x == __y); }
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     { return __y < __x; }
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     { return !(__y < __x); }
 
   /// Based on operator<
   template<typename _Tp, typename _Alloc>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
     { return !(__x < __y); }
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h
index 936cf0d2380..363868fe0a6 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -107,15 +107,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
       template<typename _Tp1, typename _Seq1>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
 
       template<typename _Tp1, typename _Seq1>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
 
 #if __cpp_lib_three_way_comparison
       template<typename _Tp1, three_way_comparable _Seq1>
+	[[nodiscard]]
 	friend compare_three_way_result_t<_Seq1>
 	operator<=>(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
 #endif
@@ -204,6 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return c.empty(); }
 
       /**  Returns the number of elements in the %queue.  */
+      _GLIBCXX_NODISCARD
       size_type
       size() const
       { return c.size(); }
@@ -212,6 +216,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read/write reference to the data at the first
        *  element of the %queue.
        */
+      _GLIBCXX_NODISCARD
       reference
       front()
       {
@@ -223,6 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %queue.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       front() const
       {
@@ -234,6 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read/write reference to the data at the last
        *  element of the %queue.
        */
+      _GLIBCXX_NODISCARD
       reference
       back()
       {
@@ -245,6 +252,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read-only (constant) reference to the data at the last
        *  element of the %queue.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       back() const
       {
@@ -340,6 +348,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  if their sequences compare equal.
   */
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return __x.c == __y.c; }
@@ -358,36 +367,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  determination.
   */
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return __x.c < __y.c; }
 
   /// Based on operator==
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return !(__x == __y); }
 
   /// Based on operator<
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return __y < __x; }
 
   /// Based on operator<
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return !(__y < __x); }
 
   /// Based on operator<
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return !(__x < __y); }
 
 #if __cpp_lib_three_way_comparison
   template<typename _Tp, three_way_comparable _Seq>
+    [[nodiscard]]
     inline compare_three_way_result_t<_Seq>
     operator<=>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     { return __x.c <=> __y.c; }
@@ -613,6 +628,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return c.empty(); }
 
       /**  Returns the number of elements in the %queue.  */
+      _GLIBCXX_NODISCARD
       size_type
       size() const
       { return c.size(); }
@@ -621,6 +637,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %queue.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       top() const
       {
diff --git a/libstdc++-v3/include/bits/stl_stack.h b/libstdc++-v3/include/bits/stl_stack.h
index 2a460d2751a..85137b9d428 100644
--- a/libstdc++-v3/include/bits/stl_stack.h
+++ b/libstdc++-v3/include/bits/stl_stack.h
@@ -200,6 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return c.empty(); }
 
       /**  Returns the number of elements in the %stack.  */
+      _GLIBCXX_NODISCARD
       size_type
       size() const
       { return c.size(); }
@@ -208,6 +209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read/write reference to the data at the first
        *  element of the %stack.
        */
+      _GLIBCXX_NODISCARD
       reference
       top()
       {
@@ -219,6 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %stack.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       top() const
       {
@@ -315,6 +318,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  equal.
   */
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return __x.c == __y.c; }
@@ -333,36 +337,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  determination.
   */
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return __x.c < __y.c; }
 
   /// Based on operator==
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return !(__x == __y); }
 
   /// Based on operator<
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return __y < __x; }
 
   /// Based on operator<
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return !(__y < __x); }
 
   /// Based on operator<
   template<typename _Tp, typename _Seq>
+    _GLIBCXX_NODISCARD
     inline bool
     operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return !(__x < __y); }
 
 #if __cpp_lib_three_way_comparison
   template<typename _Tp, three_way_comparable _Seq>
+    [[nodiscard]]
     inline compare_three_way_result_t<_Seq>
     operator<=>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     { return __x.c <=> __y.c; }
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h
index 06abf01ab0e..296da43822a 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -807,6 +807,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  element in the %vector.  Iteration is done in ordinary
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return iterator(this->_M_impl._M_start); }
@@ -816,6 +817,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  first element in the %vector.  Iteration is done in ordinary
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return const_iterator(this->_M_impl._M_start); }
@@ -825,6 +827,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  element in the %vector.  Iteration is done in ordinary
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return iterator(this->_M_impl._M_finish); }
@@ -834,6 +837,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  the last element in the %vector.  Iteration is done in
        *  ordinary element order.
        */
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return const_iterator(this->_M_impl._M_finish); }
@@ -843,6 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  last element in the %vector.  Iteration is done in reverse
        *  element order.
        */
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(end()); }
@@ -852,6 +857,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to the last element in the %vector.  Iteration is done in
        *  reverse element order.
        */
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(end()); }
@@ -861,6 +867,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  before the first element in the %vector.  Iteration is done
        *  in reverse element order.
        */
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(begin()); }
@@ -870,6 +877,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to one before the first element in the %vector.  Iteration
        *  is done in reverse element order.
        */
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(begin()); }
@@ -880,6 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  first element in the %vector.  Iteration is done in ordinary
        *  element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(this->_M_impl._M_start); }
@@ -889,6 +898,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  the last element in the %vector.  Iteration is done in
        *  ordinary element order.
        */
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return const_iterator(this->_M_impl._M_finish); }
@@ -898,6 +908,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to the last element in the %vector.  Iteration is done in
        *  reverse element order.
        */
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
@@ -907,6 +918,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to one before the first element in the %vector.  Iteration
        *  is done in reverse element order.
        */
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
@@ -914,11 +926,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
       // [23.2.4.2] capacity
       /**  Returns the number of elements in the %vector.  */
+      _GLIBCXX_NODISCARD
       size_type
       size() const _GLIBCXX_NOEXCEPT
       { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
 
       /**  Returns the size() of the largest possible %vector.  */
+      _GLIBCXX_NODISCARD
       size_type
       max_size() const _GLIBCXX_NOEXCEPT
       { return _S_max_size(_M_get_Tp_allocator()); }
@@ -994,6 +1008,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns the total number of elements that the %vector can
        *  hold before needing to allocate more memory.
        */
+      _GLIBCXX_NODISCARD
       size_type
       capacity() const _GLIBCXX_NOEXCEPT
       { return size_type(this->_M_impl._M_end_of_storage
@@ -1039,6 +1054,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  out_of_range lookups are not defined. (For checked lookups
        *  see at().)
        */
+      _GLIBCXX_NODISCARD
       reference
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -1057,6 +1073,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  out_of_range lookups are not defined. (For checked lookups
        *  see at().)
        */
+      _GLIBCXX_NODISCARD
       const_reference
       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
       {
@@ -1117,6 +1134,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write reference to the data at the first
        *  element of the %vector.
        */
+      _GLIBCXX_NODISCARD
       reference
       front() _GLIBCXX_NOEXCEPT
       {
@@ -1128,6 +1146,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) reference to the data at the first
        *  element of the %vector.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       front() const _GLIBCXX_NOEXCEPT
       {
@@ -1139,6 +1158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read/write reference to the data at the last
        *  element of the %vector.
        */
+      _GLIBCXX_NODISCARD
       reference
       back() _GLIBCXX_NOEXCEPT
       {
@@ -1150,6 +1170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  Returns a read-only (constant) reference to the data at the
        *  last element of the %vector.
        */
+      _GLIBCXX_NODISCARD
       const_reference
       back() const _GLIBCXX_NOEXCEPT
       {
@@ -1164,10 +1185,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *   Returns a pointer such that [data(), data() + size()) is a valid
        *   range.  For a non-empty %vector, data() == &front().
        */
+      _GLIBCXX_NODISCARD
       _Tp*
       data() _GLIBCXX_NOEXCEPT
       { return _M_data_ptr(this->_M_impl._M_start); }
 
+      _GLIBCXX_NODISCARD
       const _Tp*
       data() const _GLIBCXX_NOEXCEPT
       { return _M_data_ptr(this->_M_impl._M_start); }
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index 227d083da04..4257a1651bd 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -219,51 +219,63 @@ namespace __debug
       using _Base::get_allocator;
 
       // iterators:
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return iterator(_Base::begin(), this); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return const_iterator(_Base::begin(), this); }
 
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return iterator(_Base::end(), this); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return const_iterator(_Base::end(), this); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(begin()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(begin()); }
 
 #if __cplusplus >= 201103L
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(_Base::begin(), this); }
 
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return const_iterator(_Base::end(), this); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
@@ -335,6 +347,7 @@ namespace __debug
       using _Base::empty;
 
       // element access:
+      _GLIBCXX_NODISCARD
       reference
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -342,6 +355,7 @@ namespace __debug
 	return _M_base()[__n];
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
       {
@@ -351,6 +365,7 @@ namespace __debug
 
       using _Base::at;
 
+      _GLIBCXX_NODISCARD
       reference
       front() _GLIBCXX_NOEXCEPT
       {
@@ -358,6 +373,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       front() const _GLIBCXX_NOEXCEPT
       {
@@ -365,6 +381,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      _GLIBCXX_NODISCARD
       reference
       back() _GLIBCXX_NOEXCEPT
       {
@@ -372,6 +389,7 @@ namespace __debug
 	return _Base::back();
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       back() const _GLIBCXX_NOEXCEPT
       {
diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list
index 16f0531dce7..9cc05e8129c 100644
--- a/libstdc++-v3/include/debug/forward_list
+++ b/libstdc++-v3/include/debug/forward_list
@@ -327,38 +327,47 @@ namespace __debug
 
       // iterators:
 
+      [[__nodiscard__]]
       iterator
       before_begin() noexcept
       { return { _Base::before_begin(), this }; }
 
+      [[__nodiscard__]]
       const_iterator
       before_begin() const noexcept
       { return { _Base::before_begin(), this }; }
 
+      [[__nodiscard__]]
       iterator
       begin() noexcept
       { return { _Base::begin(), this }; }
 
+      [[__nodiscard__]]
       const_iterator
       begin() const noexcept
       { return { _Base::begin(), this }; }
 
+      [[__nodiscard__]]
       iterator
       end() noexcept
       { return { _Base::end(), this }; }
 
+      [[__nodiscard__]]
       const_iterator
       end() const noexcept
       { return { _Base::end(), this }; }
 
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return { _Base::cbegin(), this }; }
 
+      [[__nodiscard__]]
       const_iterator
       cbefore_begin() const noexcept
       { return { _Base::cbefore_begin(), this }; }
 
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return { _Base::cend(), this }; }
@@ -368,6 +377,7 @@ namespace __debug
 
       // element access:
 
+      [[__nodiscard__]]
       reference
       front()
       {
@@ -375,6 +385,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      [[__nodiscard__]]
       const_reference
       front() const
       {
diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list
index 01fe43fc7df..83122f8248d 100644
--- a/libstdc++-v3/include/debug/list
+++ b/libstdc++-v3/include/debug/list
@@ -223,51 +223,63 @@ namespace __debug
       using _Base::get_allocator;
 
       // iterators:
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return iterator(_Base::begin(), this); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return const_iterator(_Base::begin(), this); }
 
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return iterator(_Base::end(), this); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return const_iterator(_Base::end(), this); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(begin()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(begin()); }
 
 #if __cplusplus >= 201103L
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(_Base::begin(), this); }
 
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return const_iterator(_Base::end(), this); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
@@ -356,6 +368,7 @@ namespace __debug
 #endif
 
       // element access:
+      _GLIBCXX_NODISCARD
       reference
       front() _GLIBCXX_NOEXCEPT
       {
@@ -363,6 +376,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       front() const _GLIBCXX_NOEXCEPT
       {
@@ -370,6 +384,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      _GLIBCXX_NODISCARD
       reference
       back() _GLIBCXX_NOEXCEPT
       {
@@ -377,6 +392,7 @@ namespace __debug
 	return _Base::back();
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       back() const _GLIBCXX_NOEXCEPT
       {
diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h
index 8e138fd32e5..5584d06de5a 100644
--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -297,6 +297,7 @@ namespace __gnu_debug
        *  @brief Iterator dereference.
        *  @pre iterator is dereferenceable
        */
+      _GLIBCXX_NODISCARD
       reference
       operator*() const _GLIBCXX_NOEXCEPT
       {
@@ -310,6 +311,7 @@ namespace __gnu_debug
        *  @brief Iterator dereference.
        *  @pre iterator is dereferenceable
        */
+      _GLIBCXX_NODISCARD
       pointer
       operator->() const _GLIBCXX_NOEXCEPT
       {
@@ -463,6 +465,7 @@ namespace __gnu_debug
 
       typedef _Safe_iterator<_Iterator, _Sequence, iterator_category> _Self;
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator==(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -471,6 +474,7 @@ namespace __gnu_debug
       }
 
       template<typename _IteR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator==(const _Self& __lhs,
 	  const _Safe_iterator<_IteR, _Sequence, iterator_category>& __rhs)
@@ -481,6 +485,7 @@ namespace __gnu_debug
 	}
 
 #if ! __cpp_lib_three_way_comparison
+      _GLIBCXX_NODISCARD
       friend bool
       operator!=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -489,6 +494,7 @@ namespace __gnu_debug
       }
 
       template<typename _IteR>
+	_GLIBCXX_NODISCARD
 	friend bool
 	operator!=(const _Self& __lhs,
 	  const _Safe_iterator<_IteR, _Sequence, iterator_category>& __rhs)
@@ -786,6 +792,7 @@ namespace __gnu_debug
       }
 
       // ------ Random access iterator requirements ------
+      _GLIBCXX_NODISCARD
       reference
       operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
       {
@@ -819,6 +826,7 @@ namespace __gnu_debug
       }
 
 #if __cpp_lib_three_way_comparison
+      [[nodiscard]]
       friend auto
       operator<=>(const _Self& __lhs, const _Self& __rhs) noexcept
       {
@@ -826,6 +834,7 @@ namespace __gnu_debug
 	return __lhs.base() <=> __rhs.base();
       }
 
+      [[nodiscard]]
       friend auto
       operator<=>(const _Self& __lhs, const _OtherSelf& __rhs) noexcept
       {
@@ -833,6 +842,7 @@ namespace __gnu_debug
 	return __lhs.base() <=> __rhs.base();
       }
 #else
+      _GLIBCXX_NODISCARD
       friend bool
       operator<(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -840,6 +850,7 @@ namespace __gnu_debug
 	return __lhs.base() < __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator<(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -847,6 +858,7 @@ namespace __gnu_debug
 	return __lhs.base() < __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator<=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -854,6 +866,7 @@ namespace __gnu_debug
 	return __lhs.base() <= __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator<=(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -861,6 +874,7 @@ namespace __gnu_debug
 	return __lhs.base() <= __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator>(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -868,6 +882,7 @@ namespace __gnu_debug
 	return __lhs.base() > __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator>(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -875,6 +890,7 @@ namespace __gnu_debug
 	return __lhs.base() > __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator>=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -882,6 +898,7 @@ namespace __gnu_debug
 	return __lhs.base() >= __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend bool
       operator>=(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -894,6 +911,7 @@ namespace __gnu_debug
       // According to the resolution of DR179 not only the various comparison
       // operators but also operator- must accept mixed iterator/const_iterator
       // parameters.
+      _GLIBCXX_NODISCARD
       friend difference_type
       operator-(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -901,6 +919,7 @@ namespace __gnu_debug
 	return __lhs.base() - __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend difference_type
       operator-(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
       {
@@ -908,6 +927,7 @@ namespace __gnu_debug
 	return __lhs.base() - __rhs.base();
       }
 
+      _GLIBCXX_NODISCARD
       friend _Self
       operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -917,6 +937,7 @@ namespace __gnu_debug
 	return _Safe_iterator(__x.base() + __n, __x._M_sequence);
       }
 
+      _GLIBCXX_NODISCARD
       friend _Self
       operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT
       {
@@ -926,6 +947,7 @@ namespace __gnu_debug
 	return _Safe_iterator(__n + __x.base(), __x._M_sequence);
       }
 
+      _GLIBCXX_NODISCARD
       friend _Self
       operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
       {
diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector
index 79ccf527dd6..55271384922 100644
--- a/libstdc++-v3/include/debug/vector
+++ b/libstdc++-v3/include/debug/vector
@@ -303,51 +303,63 @@ namespace __debug
       using _Base::get_allocator;
 
       // iterators:
+      _GLIBCXX_NODISCARD
       iterator
       begin() _GLIBCXX_NOEXCEPT
       { return iterator(_Base::begin(), this); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       begin() const _GLIBCXX_NOEXCEPT
       { return const_iterator(_Base::begin(), this); }
 
+      _GLIBCXX_NODISCARD
       iterator
       end() _GLIBCXX_NOEXCEPT
       { return iterator(_Base::end(), this); }
 
+      _GLIBCXX_NODISCARD
       const_iterator
       end() const _GLIBCXX_NOEXCEPT
       { return const_iterator(_Base::end(), this); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rbegin() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rbegin() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(end()); }
 
+      _GLIBCXX_NODISCARD
       reverse_iterator
       rend() _GLIBCXX_NOEXCEPT
       { return reverse_iterator(begin()); }
 
+      _GLIBCXX_NODISCARD
       const_reverse_iterator
       rend() const _GLIBCXX_NOEXCEPT
       { return const_reverse_iterator(begin()); }
 
 #if __cplusplus >= 201103L
+      [[__nodiscard__]]
       const_iterator
       cbegin() const noexcept
       { return const_iterator(_Base::begin(), this); }
 
+      [[__nodiscard__]]
       const_iterator
       cend() const noexcept
       { return const_iterator(_Base::end(), this); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
@@ -407,6 +419,7 @@ namespace __debug
       }
 #endif
 
+      _GLIBCXX_NODISCARD
       size_type
       capacity() const _GLIBCXX_NOEXCEPT
       {
@@ -431,6 +444,7 @@ namespace __debug
       }
 
       // element access:
+      _GLIBCXX_NODISCARD
       reference
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       {
@@ -438,6 +452,7 @@ namespace __debug
 	return _M_base()[__n];
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
       {
@@ -447,6 +462,7 @@ namespace __debug
 
       using _Base::at;
 
+      _GLIBCXX_NODISCARD
       reference
       front() _GLIBCXX_NOEXCEPT
       {
@@ -454,6 +470,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       front() const _GLIBCXX_NOEXCEPT
       {
@@ -461,6 +478,7 @@ namespace __debug
 	return _Base::front();
       }
 
+      _GLIBCXX_NODISCARD
       reference
       back() _GLIBCXX_NOEXCEPT
       {
@@ -468,6 +486,7 @@ namespace __debug
 	return _Base::back();
       }
 
+      _GLIBCXX_NODISCARD
       const_reference
       back() const _GLIBCXX_NOEXCEPT
       {
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index ea8d3cb5f2e..3e12d35157c 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -127,65 +127,81 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { std::swap_ranges(begin(), end(), __other.begin()); }
 
       // Iterators.
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR iterator
       begin() noexcept
       { return iterator(data()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_iterator
       begin() const noexcept
       { return const_iterator(data()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR iterator
       end() noexcept
       { return iterator(data() + _Nm); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_iterator
       end() const noexcept
       { return const_iterator(data() + _Nm); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reverse_iterator
       rbegin() noexcept
       { return reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_reverse_iterator
       rbegin() const noexcept
       { return const_reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reverse_iterator
       rend() noexcept
       { return reverse_iterator(begin()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_reverse_iterator
       rend() const noexcept
       { return const_reverse_iterator(begin()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_iterator
       cbegin() const noexcept
       { return const_iterator(data()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_iterator
       cend() const noexcept
       { return const_iterator(data() + _Nm); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_reverse_iterator
       crbegin() const noexcept
       { return const_reverse_iterator(end()); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_reverse_iterator
       crend() const noexcept
       { return const_reverse_iterator(begin()); }
 
       // Capacity.
+      [[__nodiscard__]]
       constexpr size_type
       size() const noexcept { return _Nm; }
 
+      [[__nodiscard__]]
       constexpr size_type
       max_size() const noexcept { return _Nm; }
 
-      _GLIBCXX_NODISCARD constexpr bool
+      [[__nodiscard__]]
+      constexpr bool
       empty() const noexcept { return size() == 0; }
 
       // Element access.
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reference
       operator[](size_type __n) noexcept
       {
@@ -193,6 +209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return _AT_Type::_S_ref(_M_elems, __n);
       }
 
+      [[__nodiscard__]]
       constexpr const_reference
       operator[](size_type __n) const noexcept
       {
@@ -224,6 +241,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	     _AT_Type::_S_ref(_M_elems, 0));
       }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reference
       front() noexcept
       {
@@ -231,6 +249,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *begin();
       }
 
+      [[__nodiscard__]]
       constexpr const_reference
       front() const noexcept
       {
@@ -240,6 +259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return _AT_Type::_S_ref(_M_elems, 0);
       }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR reference
       back() noexcept
       {
@@ -247,6 +267,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return _Nm ? *(end() - 1) : *end();
       }
 
+      [[__nodiscard__]]
       constexpr const_reference
       back() const noexcept
       {
@@ -257,10 +278,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  	           : _AT_Type::_S_ref(_M_elems, 0);
       }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR pointer
       data() noexcept
       { return _AT_Type::_S_ptr(_M_elems); }
 
+      [[__nodiscard__]]
       _GLIBCXX17_CONSTEXPR const_pointer
       data() const noexcept
       { return _AT_Type::_S_ptr(_M_elems); }
@@ -275,6 +298,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Array comparisons.
   template<typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     _GLIBCXX20_CONSTEXPR
     inline bool
     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
@@ -282,6 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cpp_lib_three_way_comparison && __cpp_lib_concepts
   template<typename _Tp, size_t _Nm>
+    [[nodiscard]]
     constexpr __detail::__synth3way_t<_Tp>
     operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
     {
@@ -304,12 +329,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 #else
   template<typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     _GLIBCXX20_CONSTEXPR
     inline bool
     operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
     { return !(__one == __two); }
 
   template<typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     _GLIBCXX20_CONSTEXPR
     inline bool
     operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
@@ -319,18 +346,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     _GLIBCXX20_CONSTEXPR
     inline bool
     operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
     { return __two < __one; }
 
   template<typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     _GLIBCXX20_CONSTEXPR
     inline bool
     operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
     { return !(__one > __two); }
 
   template<typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     _GLIBCXX20_CONSTEXPR
     inline bool
     operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
@@ -361,6 +391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     constexpr _Tp&
     get(array<_Tp, _Nm>& __arr) noexcept
     {
@@ -369,6 +400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     constexpr _Tp&&
     get(array<_Tp, _Nm>&& __arr) noexcept
     {
@@ -377,6 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     constexpr const _Tp&
     get(const array<_Tp, _Nm>& __arr) noexcept
     {
@@ -385,6 +418,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+    [[__nodiscard__]]
     constexpr const _Tp&&
     get(const array<_Tp, _Nm>&& __arr) noexcept
     {
@@ -406,6 +440,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<typename _Tp, size_t _Nm>
+    [[nodiscard]]
     constexpr array<remove_cv_t<_Tp>, _Nm>
     to_array(_Tp (&__a)[_Nm])
     noexcept(is_nothrow_constructible_v<_Tp, _Tp&>)
@@ -418,6 +453,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   template<typename _Tp, size_t _Nm>
+    [[nodiscard]]
     constexpr array<remove_cv_t<_Tp>, _Nm>
     to_array(_Tp (&&__a)[_Nm])
     noexcept(is_nothrow_move_constructible_v<_Tp>)
diff --git a/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc b/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc
index c286b35fd61..e3cb6990f59 100644
--- a/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc
@@ -1,4 +1,4 @@
-// { dg-options "-std=gnu++2a" }
+// { dg-options "-std=gnu++2a -Wno-unused-result" }
 // { dg-do compile { target c++2a } }
 
 // Copyright (C) 2019-2021 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc
index d384b7b2ff4..01c7c45784e 100644
--- a/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc
@@ -23,7 +23,7 @@
 void test01()
 {
   std::array<int, 0> a;
-  a.back();
+  (void) a.back();
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc
index b27f5f0bb03..db195e86411 100644
--- a/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc
@@ -23,7 +23,7 @@
 void test01()
 {
   constexpr std::array<int, 0> a;
-  a.back();
+  (void) a.back();
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc
index e0d86f1c07f..700f8524950 100644
--- a/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc
@@ -23,7 +23,7 @@
 void test01()
 {
   std::array<int, 0> a;
-  a.front();
+  (void) a.front();
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc
index dcbe5b6dd2e..d84b301fbf8 100644
--- a/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc
@@ -23,7 +23,7 @@
 void test01()
 {
   constexpr std::array<int, 0> a;
-  a.front();
+  (void) a.front();
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc
index 299ba85a5cf..bc5db43e123 100644
--- a/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc
@@ -23,7 +23,7 @@
 void test01()
 {
   std::array<int, 0> a;
-  a[0];
+  (void) a[0];
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc
index 36d281af105..105952f36d9 100644
--- a/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc
@@ -23,7 +23,7 @@
 void test01()
 {
   constexpr std::array<int, 0> a;
-  a[0];
+  (void) a[0];
 }
 
 int main()
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 423594dd2b3..70742c14a7d 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 *-*-* } 367 }
-// { dg-error "static assertion failed" "" { target *-*-* } 375 }
-// { dg-error "static assertion failed" "" { target *-*-* } 383 }
+// { dg-error "static assertion failed" "" { target *-*-* } 398 }
+// { dg-error "static assertion failed" "" { target *-*-* } 407 }
+// { dg-error "static assertion failed" "" { target *-*-* } 416 }
diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc
index 29fdd46115b..12063f53bb9 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc
@@ -5,12 +5,12 @@
 // terms of the GNU General Public License as published by the
 // Free Software Foundation; either version 3, or (at your option)
 // any later version.
- 
+
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
- 
+
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
@@ -22,12 +22,12 @@ using namespace std;
 using __gnu_cxx::new_allocator;
 
 template<typename T>
-  class clear_alloc : public new_allocator<T> 
+  class clear_alloc : public new_allocator<T>
   {
   public:
 
     template <typename T1>
-      struct rebind 
+      struct rebind
       { typedef clear_alloc<T1> other; };
 
     virtual void clear() throw()
@@ -35,10 +35,10 @@ template<typename T>
 
     clear_alloc() throw()
     { }
-    
-    clear_alloc(clear_alloc const&) throw() : new_allocator<T>() 
+
+    clear_alloc(clear_alloc const&) throw() : new_allocator<T>()
     { }
-    
+
     template<typename T1>
     clear_alloc(clear_alloc<T1> const&) throw()
       { }
@@ -51,7 +51,7 @@ template<typename T>
       this->clear();
       return new_allocator<T>::allocate(n, hint);
     }
-    
+
     void deallocate(T *ptr, typename new_allocator<T>::size_type n)
     {
       this->clear();
@@ -64,14 +64,14 @@ template<typename Container>
   {
     Container* pic = new Container;
     int x = 230;
-    
+
     while (x--)
       {
 	pic->push_back(x);
       }
-    
-    pic->get_allocator();
-    
+
+    (void) pic->get_allocator();
+
     // The following has led to infinite recursions or cores.
     pic->clear();
 
diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc
index 6ec8b620422..aa98b7f6608 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc
@@ -58,7 +58,7 @@ void test04()
   before = v.begin();
   at = before + 3;
   v.erase(at, v.end());
-  *before;
+  (void) *before;
 
   // clear()
   before = v.begin();
diff --git a/libstdc++-v3/testsuite/23_containers/deque/types/1.cc b/libstdc++-v3/testsuite/23_containers/deque/types/1.cc
index a17b1d86ec9..144eb57e13a 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/types/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/types/1.cc
@@ -18,6 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
+// { dg-options "-Wno-unused-result" }
 
 #include <deque>
 #include <testsuite_greedy_ops.h>
diff --git a/libstdc++-v3/testsuite/23_containers/list/types/1.cc b/libstdc++-v3/testsuite/23_containers/list/types/1.cc
index 1e649963b84..45222b93bce 100644
--- a/libstdc++-v3/testsuite/23_containers/list/types/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/types/1.cc
@@ -25,7 +25,7 @@ int main()
   std::list<greedy_ops::X> l;
   const std::list<greedy_ops::X> cl;
 
-  l.size();
+  (void) l.size();
   l.insert(l.begin(), greedy_ops::X());
   l.insert(l.begin(), 1, greedy_ops::X());
   l.insert(l.begin(), cl.begin(), cl.end());
diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc
index 951b667c555..3ab3d337f46 100644
--- a/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc
+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc
@@ -32,7 +32,7 @@ test03()
   for (int i = 0; i < 3; ++i)
     pq.push(data[i]);
 
-  pq.top();
+  (void) pq.top();
   for (int i = 0; i < 2; ++i)
     pq.pop();
 
diff --git a/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc b/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc
index b01201a968e..e3e5dda2ef0 100644
--- a/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc
+++ b/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc
@@ -29,7 +29,7 @@ test01()
   std::queue<int> q;
 
   q.push(1);
-  q.front();
+  (void) q.front();
   q.pop();
 }
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/59829.cc b/libstdc++-v3/testsuite/23_containers/vector/59829.cc
index 16bfb6fb327..7a7f577a643 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/59829.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/59829.cc
@@ -63,5 +63,5 @@ bool operator!=(Alloc<T> l, Alloc<T> r) { return false; }
 int main()
 {
   std::vector<int, Alloc<int>> a;
-  a.data();
+  (void) a.data();
 }
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc
index 3d2fe29389d..7656f840448 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc
@@ -46,10 +46,10 @@ int main()
   std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
   const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
 
-  v[0];
-  w[0];
-  v.size();
-  v.capacity();
+  (void) v[0];
+  (void) w[0];
+  (void) v.size();
+  (void) v.capacity();
   v.resize(1);
   v.insert(v.begin(), N::X());
   v.insert(v.begin(), 1, N::X());
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc
index 9e01e8f607d..7329712a2a1 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc
@@ -48,10 +48,10 @@ int main()
   std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
   const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
 
-  v[0];
-  w[0];
-  v.size();
-  v.capacity();
+  (void) v[0];
+  (void) w[0];
+  (void) v.size();
+  (void) v.capacity();
   v.resize(1);
   v.insert(v.begin(), N::X());
   v.insert(v.begin(), 1, N::X());
diff --git a/libstdc++-v3/testsuite/23_containers/vector/types/1.cc b/libstdc++-v3/testsuite/23_containers/vector/types/1.cc
index 803f658eedd..7295a64a008 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/types/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/types/1.cc
@@ -18,6 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
+// { dg-options "-Wno-unused-result" }
 
 #include <vector>
 #include <testsuite_greedy_ops.h>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-04 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 11:55 [gcc r12-2730] libstdc++: Add [[nodiscard]] to sequence containers Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).