[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:22:56 PST 2025
================
@@ -1383,8 +1383,9 @@ first_trailing_zero(T value) {
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
first_trailing_one(T value) {
- return value == cpp::numeric_limits<T>::max() ? 0
----------------
lntue wrote:
it should be just `value == 0`. When `value` is not 0, `cpp::countr_zero(value) + 1` should be correct.
https://github.com/llvm/llvm-project/pull/130155
More information about the libc-commits
mailing list