[libc-commits] [libc] [libc] `first_trailing_one(0)` should be `0`. (PR #130155)
via libc-commits
libc-commits at lists.llvm.org
Thu Mar 6 14:26:05 PST 2025
================
@@ -146,8 +146,9 @@ first_trailing_zero(T value) {
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
first_trailing_one(T value) {
- return value == cpp::numeric_limits<T>::max() ? 0
- : cpp::countr_zero(value) + 1;
+ return (value == 0 || value == cpp::numeric_limits<T>::max())
----------------
lntue wrote:
it should be just `value == 0`, the other case is `cpp::countr_zero(value) + 1`
https://github.com/llvm/llvm-project/pull/130155
More information about the libc-commits
mailing list