]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use explicit cast to unsigned in std::rotr and std::rotl
authorJonathan Wakely <jwakely@redhat.com>
Thu, 29 May 2025 10:29:38 +0000 (11:29 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 3 Jun 2025 09:53:00 +0000 (10:53 +0100)
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>
libstdc++-v3/include/std/bit

index 5187c96182f586bf1929d82ff09a97fb6ef90c76..fd75edf6554a82e938e2ce5b40fca0158fda6be9 100644 (file)
@@ -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;