[PATCH] libstdc++: Use explicit cast to unsigned in std::rotr and std::rotl
Jonathan Wakely
jwakely@redhat.com
Mon Jun 2 17:23:43 GMT 2025
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.
---
Tested x86_64-linux.
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..02d7189f1a3d 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 unsigned __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 unsigned __r = static_cast<unsigned>(__s);
return (__x >> (__r % __uNd)) | (__x << ((-__r) % __uNd));
}
const int __r = __s % _Nd;
--
2.49.0
More information about the Libstdc++
mailing list