Skip to content

Commit

Permalink
fix cuda::std::bit_width() return type (NVIDIA#2745)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbusato authored Nov 8, 2024
1 parent bfc71bb commit 8ed4a20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__bit/integral.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ bit_ceil(_Tp __t) noexcept
}

template <class _Tp>
_LIBCUDACXX_HIDE_FROM_ABI constexpr __enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
_LIBCUDACXX_HIDE_FROM_ABI constexpr __enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
bit_width(_Tp __t) noexcept
{
return __t == 0 ? 0 : static_cast<_Tp>(__bit_log2(__t) + 1);
return __t == 0 ? 0 : static_cast<int>(__bit_log2(__t) + 1);
}

_LIBCUDACXX_END_NAMESPACE_STD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ __host__ __device__ constexpr bool constexpr_test()
template <typename T>
__host__ __device__ void runtime_test()
{
ASSERT_SAME_TYPE(T, decltype(cuda::std::bit_width(T(0))));
ASSERT_SAME_TYPE(int, decltype(cuda::std::bit_width(T(0))));
ASSERT_NOEXCEPT(cuda::std::bit_width(T(0)));

assert(cuda::std::bit_width(T(0)) == T(0));
Expand Down

0 comments on commit 8ed4a20

Please sign in to comment.