diff mbox series

[committed] libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite

Message ID 20240927204207.2349486-1-jwakely@redhat.com
State New
Headers show
Series [committed] libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite | expand

Commit Message

Jonathan Wakely Sept. 27, 2024, 8:41 p.m. UTC
Tested x86_64-linux. Pushed to trunk.

-- >8 --

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc (resize_for_overwrite): Fix
	-Wsign-compare warning.
	* include/bits/cow_string.h (resize_for_overwrite): Likewise.
---
 libstdc++-v3/include/bits/basic_string.tcc | 2 +-
 libstdc++-v3/include/bits/cow_string.h     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 2c17d258bfe..caeddaf2f5b 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -611,7 +611,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();
diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h
index b78aa74fbfa..087ddf81dd8 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -3800,7 +3800,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();