https://gcc.gnu.org/g:c2ccc43dda153ce707d39c46623b0d30ceca7db8

commit r16-4119-gc2ccc43dda153ce707d39c46623b0d30ceca7db8
Author: Jonathan Wakely <[email protected]>
Date:   Sat Sep 27 12:47:45 2025 +0100

    libstdc++: Fix some -Wsign-compare warnings in headers
    
    In all these cases we know the value with signed type is not negative so
    the cast is safe.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/deque.tcc (deque::_M_shrink_to_fit): Cast
            difference_type to size_type to avoid -Wsign-compare warning.
            * include/std/spanstream (basic_spanbuf::seekoff): Cast
            streamoff to size_t to avoid -Wsign-compare warning.

Diff:
---
 libstdc++-v3/include/bits/deque.tcc | 2 +-
 libstdc++-v3/include/std/spanstream | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/deque.tcc 
b/libstdc++-v3/include/bits/deque.tcc
index c15b046691ea..20b23fffc9e1 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -381,7 +381,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
       const difference_type __back_capacity
        = (this->_M_impl._M_finish._M_last - this->_M_impl._M_finish._M_cur);
-      if (__front_capacity + __back_capacity < _S_buffer_size())
+      if (size_type(__front_capacity + __back_capacity) < _S_buffer_size())
        return false;
 
       return std::__shrink_to_fit_aux<deque>::_S_do_it(*this);
diff --git a/libstdc++-v3/include/std/spanstream 
b/libstdc++-v3/include/std/spanstream
index 23a340a746e8..fbb40ff1db26 100644
--- a/libstdc++-v3/include/std/spanstream
+++ b/libstdc++-v3/include/std/spanstream
@@ -152,7 +152,7 @@ template<typename _CharT, typename _Traits>
 
       if (__way == ios_base::beg)
        {
-         if (0 <= __off && __off <= _M_buf.size())
+         if (0 <= __off && (size_t)__off <= _M_buf.size())
            {
              if (__which & ios_base::in)
                this->setg(this->eback(), this->eback() + __off, this->egptr());
@@ -188,7 +188,7 @@ template<typename _CharT, typename _Traits>
          if (__builtin_add_overflow(__base, __off, &__off)) [[unlikely]]
            return __ret;
 
-         if (__off < 0 || __off > _M_buf.size()) [[unlikely]]
+         if (__off < 0 || (size_t)__off > _M_buf.size()) [[unlikely]]
            return __ret;
 
          if (__which & ios_base::in)

Reply via email to