libstdc++: Fix -Wsign-compare warnings in headers
authorJonathan Wakely <jwakely@redhat.com>
Tue, 27 Oct 2020 16:32:53 +0000 (16:32 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 27 Oct 2020 16:32:53 +0000 (16:32 +0000)
libstdc++-v3/ChangeLog:

* include/bits/locale_conv.h (__str_codecvt_out_all):
Add cast to compare operands of the same signedness.
* include/bits/locale_facets_nonio.tcc
(time_get::_M_extract_wday_or_month): Likewise.
* include/bits/sstream.tcc (basic_stringbuf::overflow):
Likewise.
* include/tr1/legendre_function.tcc (__sph_legendre): Use
unsigned for loop variable.

libstdc++-v3/include/bits/locale_conv.h
libstdc++-v3/include/bits/locale_facets_nonio.tcc
libstdc++-v3/include/bits/sstream.tcc
libstdc++-v3/include/tr1/legendre_function.tcc

index f1d7032..52c37a4 100644 (file)
@@ -185,7 +185,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _State __state = {};
       size_t __n;
       return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n)
-       && (__n == (__last - __first));
+       && (__n == size_t(__last - __first));
     }
 
 #ifdef _GLIBCXX_USE_CHAR8_T
index ff84d73..a8639f6 100644 (file)
@@ -1046,8 +1046,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
       if ((__nmatches == 1 && __matches_lengths[0] == __pos)
          || (__nmatches == 2 && (__matches_lengths[0] == __pos
                                  || __matches_lengths[1] == __pos)))
-       __member = (__matches[0] >= __indexlen
-                   ? __matches[0] - __indexlen : __matches[0]);
+       __member = (__matches[0] >= (int)__indexlen
+                   ? __matches[0] - (int)__indexlen : __matches[0]);
       else
        __err |= ios_base::failbit;
 
index 9e70c36..5dd0600 100644 (file)
@@ -90,7 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const __size_type __capacity = _M_string.capacity();
 
 #if _GLIBCXX_USE_CXX11_ABI
-      if ((this->epptr() - this->pbase()) < __capacity)
+      if (size_t(this->epptr() - this->pbase()) < __capacity)
        {
          // There is additional capacity in _M_string that can be used.
          char_type* __base = const_cast<char_type*>(_M_string.data());
index 126355b..1e66a5a 100644 (file)
@@ -274,7 +274,7 @@ namespace tr1
               _Tp __y_lm = _Tp(0);
 
               // Compute Y_l^m, l > m+1, upward recursion on l.
-              for (int __ll = __m + 2; __ll <= __l; ++__ll)
+              for (unsigned int __ll = __m + 2; __ll <= __l; ++__ll)
                 {
                   const _Tp __rat1 = _Tp(__ll - __m) / _Tp(__ll + __m);
                   const _Tp __rat2 = _Tp(__ll - __m - 1) / _Tp(__ll + __m - 1);