[libc-commits] [libc] [libc] `first_trailing_one(0)` should be `0`. (PR #130155)
Connector Switch via libc-commits
libc-commits at lists.llvm.org
Thu Mar 6 18:11:49 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
----------------
c8ef wrote:
It will fail with inputs like `USHRT_MAX` because we need it to return 0, but `cpp::countr_zero(USHRT_MAX) + 1 = 1`.
https://github.com/llvm/llvm-project/pull/130155
More information about the libc-commits
mailing list