[libc-commits] [libc] [libc] Make `stdc_first_trailing_one` spec compliant (PR #116493)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Mon Dec 2 12:06:40 PST 2024
================
@@ -146,8 +146,7 @@ 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 == T(0) ? 0 : cpp::countr_zero(value) + 1;
----------------
nickdesaulniers wrote:
I'm not concerned with platforms where `sizeof(short) == sizeof(int)`; if we need to support those, ever, there will need to be other changes throughout llvm-libc. At that point, I'd prefer to know what platforms those are, and who cares about them, such that we can then stand up proper CI upstream for ensuring we don't break them.
https://github.com/llvm/llvm-project/pull/116493
More information about the libc-commits
mailing list