[gcc r16-1074] libstdc++: Use explicit cast to unsigned in std::rotr and std::rotl
Jonathan Wakely
redi@gcc.gnu.org
Tue Jun 3 09:53:30 GMT 2025
https://gcc.gnu.org/g:f12151e527d8d1b39a26b196f3de768c7edce5d0
commit r16-1074-gf12151e527d8d1b39a26b196f3de768c7edce5d0
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu May 29 11:29:38 2025 +0100
libstdc++: Use explicit cast to unsigned in std::rotr and std::rotl
This suppresses some -Wsign-conversion warnings from Clang when
compiling with -Wsystem-headers.
libstdc++-v3/ChangeLog:
* include/std/bit (__rotl, __rotr): Use static_cast for
conversion from int to unsigned.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diff:
---
libstdc++-v3/include/std/bit | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index 5187c96182f5..fd75edf6554a 100644
--- a/libstdc++-v3/include/std/bit
+++ b/libstdc++-v3/include/std/bit
@@ -166,7 +166,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Variant for power of two _Nd which the compiler can
// easily pattern match.
constexpr unsigned __uNd = _Nd;
- const unsigned __r = __s;
+ const auto __r = static_cast<unsigned>(__s);
return (__x << (__r % __uNd)) | (__x >> ((-__r) % __uNd));
}
const int __r = __s % _Nd;
@@ -188,7 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Variant for power of two _Nd which the compiler can
// easily pattern match.
constexpr unsigned __uNd = _Nd;
- const unsigned __r = __s;
+ const auto __r = static_cast<unsigned>(__s);
return (__x >> (__r % __uNd)) | (__x << ((-__r) % __uNd));
}
const int __r = __s % _Nd;
More information about the Libstdc++-cvs
mailing list