[libcxx-commits] [libcxx] b88af66 - [libc++] Don't bother asserting that <bit> functions get unsigned types (#161487)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 7 01:29:23 PDT 2025
Author: Nikolas Klauser
Date: 2025-10-07T10:29:20+02:00
New Revision: b88af6635c2009402b15b2b9c8975ede02cd1a5d
URL: https://github.com/llvm/llvm-project/commit/b88af6635c2009402b15b2b9c8975ede02cd1a5d
DIFF: https://github.com/llvm/llvm-project/commit/b88af6635c2009402b15b2b9c8975ede02cd1a5d.diff
LOG: [libc++] Don't bother asserting that <bit> functions get unsigned types (#161487)
The builtins already diagnose types other than unsigned integers, so
there is no point in `static_assert`ing that again.
Added:
Modified:
libcxx/include/__bit/countl.h
libcxx/include/__bit/countr.h
libcxx/include/__bit/popcount.h
Removed:
################################################################################
diff --git a/libcxx/include/__bit/countl.h b/libcxx/include/__bit/countl.h
index 29b01277fb0eb..c95828f58d61a 100644
--- a/libcxx/include/__bit/countl.h
+++ b/libcxx/include/__bit/countl.h
@@ -24,7 +24,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
- static_assert(__is_unsigned_integer_v<_Tp>, "__countl_zero requires an unsigned integer type");
return __builtin_clzg(__t, numeric_limits<_Tp>::digits);
}
diff --git a/libcxx/include/__bit/countr.h b/libcxx/include/__bit/countr.h
index 4de887ad4f67c..16f689d6da383 100644
--- a/libcxx/include/__bit/countr.h
+++ b/libcxx/include/__bit/countr.h
@@ -24,7 +24,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT {
- static_assert(__is_unsigned_integer_v<_Tp>, "__countr_zero only works with unsigned types");
return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);
}
diff --git a/libcxx/include/__bit/popcount.h b/libcxx/include/__bit/popcount.h
index 8d9ba09938482..d104c8e8f0a98 100644
--- a/libcxx/include/__bit/popcount.h
+++ b/libcxx/include/__bit/popcount.h
@@ -23,7 +23,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT {
- static_assert(__is_unsigned_integer_v<_Tp>, "__popcount only works with unsigned types");
return __builtin_popcountg(__t);
}
More information about the libcxx-commits
mailing list