]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite
authorJonathan Wakely <jwakely@redhat.com>
Fri, 27 Sep 2024 14:51:56 +0000 (15:51 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 2 Dec 2024 22:41:41 +0000 (22:41 +0000)
libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc (resize_for_overwrite): Fix
-Wsign-compare warning.
* include/bits/cow_string.h (resize_for_overwrite): Likewise.

(cherry picked from commit 7040c207baa6b5d5f6065a47dd3559f3d3974a1b)

libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/include/bits/cow_string.h

index e458c1880b2e8aef24ef1445eb81091c67122df0..b7a68dd7a4863848850ab78d8e1420d324e23e85 100644 (file)
@@ -606,7 +606,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(__gnu_cxx::__is_integer_nonstrict<decltype(__r)>::__value,
                    "resize_and_overwrite operation must return an integer");
 #endif
-      _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n);
+      _GLIBCXX_DEBUG_ASSERT(__r >= 0 && size_type(__r) <= __n);
       __term._M_r = size_type(__r);
       if (__term._M_r > __n)
        __builtin_unreachable();
index 36599a2042351452a8b02964573361a7549080b0..313f235b6e6fcce2123ae4d85bd0dbf68e957010 100644 (file)
@@ -3790,7 +3790,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(__gnu_cxx::__is_integer_nonstrict<decltype(__r)>::__value,
                    "resize_and_overwrite operation must return an integer");
 #endif
-      _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n);
+      _GLIBCXX_DEBUG_ASSERT(__r >= 0 && size_type(__r) <= __n);
       __term._M_r = size_type(__r);
       if (__term._M_r > __n)
        __builtin_unreachable();