Clz builtin may be not constexpr (Issue #2761) (#2762)

This commit is contained in:
Vladislav Shchapov 2022-02-15 07:19:06 +05:00 committed by GitHub
parent ba6f89c76e
commit 0a24a0714e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -991,7 +991,7 @@ FMT_CONSTEXPR20 inline auto count_digits(uint64_t n) -> int {
template <int BITS, typename UInt>
FMT_CONSTEXPR auto count_digits(UInt n) -> int {
#ifdef FMT_BUILTIN_CLZ
if (num_bits<UInt>() == 32)
if (!is_constant_evaluated() && num_bits<UInt>() == 32)
return (FMT_BUILTIN_CLZ(static_cast<uint32_t>(n) | 1) ^ 31) / BITS + 1;
#endif
// Lambda avoids unreachable code warnings from NVHPC.