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 f1d7032e8bcba7d8209e48fd3ef9d5a7388581cc..52c37a4feac19c1d8a493a0a46e720a10a143729 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 ff84d7349cdc546bd9d77b227e2898f871c83f93..a8639f6ba28a67c6bc90fb3e2ae7e690be8f9cf2 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 9e70c36d0717758819783632179eae7275d44fc4..5dd06002a0cbfef506d6c08ca296f371f54b199b 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 126355beb31bc4378fec63452a0685de05e21f3f..1e66a5a2e571f8dc87f1f213943d1c290d22bbb4 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);