]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: avoid -Wsign-compare
authorJason Merrill <jason@redhat.com>
Tue, 27 Aug 2024 17:17:20 +0000 (13:17 -0400)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 2 Dec 2024 22:41:43 +0000 (22:41 +0000)
-Wsign-compare complained about these comparisons between (unsigned) size_t
and (signed) streamsize, or between (unsigned) native_handle_type
and (signed) -1.  Fixed by adding casts to unify the types.

libstdc++-v3/ChangeLog:

* include/std/istream: Add cast to avoid -Wsign-compare.
* include/std/stacktrace: Likewise.

(cherry picked from commit 4246cf4f18053eeb47cb2a241fffa9a41573916e)

libstdc++-v3/include/std/istream
libstdc++-v3/include/std/stacktrace

index a2b207dae78cfdd318cc563f314971e11da3b45c..730e413c290b8ab4f8802d538407b3812255e705 100644 (file)
@@ -909,7 +909,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          __n /= sizeof(_CharT);
          streamsize __w = __in.width();
          std::__istream_extract(__in, __s, __n);
-         if (__in.good() && (__w <= 0 || __n < __w))
+         if (__in.good() && (__w <= 0 || __n < (size_t)__w))
            {
              // Stopped extracting early to avoid overflowing the buffer,
              // but might have stopped anyway (and set eofbit) if at EOF.
index 8c645a8540a83e627a9f0a5b1e4f7818a7e37dfc..dcff886c095f8b38fe2c482a956e59daa3f24d90 100644 (file)
@@ -79,7 +79,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     constexpr native_handle_type
     native_handle() const noexcept { return _M_pc; }
 
-    constexpr explicit operator bool() const noexcept { return _M_pc != -1; }
+    constexpr explicit operator bool() const noexcept
+    { return _M_pc != (native_handle_type)-1; }
 
     // [stacktrace.entry.query], query
     [[nodiscard]]