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 [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t, int> countl_one(T value) { - return cpp::countl_zero(~value); + return cpp::countl_zero(static_cast(~value)); } /// Count the number of ones from the least significant bit to the first @@ -175,7 +175,7 @@ countl_one(T value) { template [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t, int> countr_one(T value) { - return cpp::countr_zero(~value); + return cpp::countr_zero(static_cast(~value)); } /// Returns the number of bits needed to represent value if value is nonzero.