[libc-commits] [libc] [Libc] Two more implicit to explicit cast changes (PR #130638)
Jan Patrick Lehr via libc-commits
libc-commits at lists.llvm.org
Mon Mar 10 09:49:53 PDT 2025
https://github.com/jplehr created https://github.com/llvm/llvm-project/pull/130638
Those two instances were also flagged with a warning after https://github.com/llvm/llvm-project/pull/126846 landed
and broke the build in two of our bots, e.g., https://lab.llvm.org/buildbot/#/builders/10/builds/1004.
I believe using type T here makes sense, but I can very well be wrong.
>From 68cac73ef58cf22ac2bb258bc20adf183f15f364 Mon Sep 17 00:00:00 2001
From: JP Lehr <JanPatrick.Lehr at amd.com>
Date: Mon, 10 Mar 2025 11:45:57 -0500
Subject: [PATCH] [Libc] Two more implicit to explicit cast changes
Those two instanced were also flagged with a warning after
https://github.com/llvm/llvm-project/pull/126846 landed.
I believe using type T here makes sense, but I can very well be wrong.
---
libc/src/__support/CPP/bit.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h
index 7d138201783bf..e491f3e032669 100644
--- a/libc/src/__support/CPP/bit.h
+++ b/libc/src/__support/CPP/bit.h
@@ -162,7 +162,7 @@ ADD_SPECIALIZATION(countl_zero, unsigned long long, __builtin_clzll)
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
countl_one(T value) {
- return cpp::countl_zero<T>(~value);
+ return cpp::countl_zero<T>(static_cast<T>(~value));
}
/// Count the number of ones from the least significant bit to the first
@@ -175,7 +175,7 @@ countl_one(T value) {
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
countr_one(T value) {
- return cpp::countr_zero<T>(~value);
+ return cpp::countr_zero<T>(static_cast<T>(~value));
}
/// Returns the number of bits needed to represent value if value is nonzero.
More information about the libc-commits
mailing list