Skip to content

Commit

Permalink
Fix assert handling
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Sep 17, 2024
1 parent ed1d6ab commit 4500e82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/__cmath/ceil_div.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# pragma system_header
#endif // no system header

#include <cuda/std/__cccl/assert.h>
#include <cuda/std/__type_traits/common_type.h>
#include <cuda/std/__type_traits/enable_if.h>
#include <cuda/std/__type_traits/is_enum.h>
Expand All @@ -29,7 +30,6 @@
#include <cuda/std/__type_traits/is_unsigned.h>
#include <cuda/std/__type_traits/make_unsigned.h>
#include <cuda/std/__type_traits/underlying_type.h>
#include <cuda/std/detail/libcxx/include/__debug>

_LIBCUDACXX_BEGIN_NAMESPACE_CUDA

Expand All @@ -44,7 +44,7 @@ template <class _Tp,
_CUDA_VSTD::__enable_if_t<_CCCL_TRAIT(_CUDA_VSTD::is_integral, _Up), int> = 0>
_CCCL_NODISCARD _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _Tp ceil_div(const _Tp __a, const _Up __b) noexcept
{
_LIBCUDACXX_DEBUG_ASSERT(__b > _Tp(0), "cuda::ceil_div: b must be positive");
_CCCL_ASSERT(__b > _Tp(0), "cuda::ceil_div: b must be positive");
using _UCommon = _CUDA_VSTD::__make_unsigned_t<_CUDA_VSTD::__common_type_t<_Tp, _Up>>;
const auto __res = static_cast<_UCommon>(__a) / static_cast<_UCommon>(__b);
return static_cast<_Tp>(__res + (__res * static_cast<_UCommon>(__b) != static_cast<_UCommon>(__a)));
Expand All @@ -61,8 +61,8 @@ template <class _Tp,
_CUDA_VSTD::__enable_if_t<_CCCL_TRAIT(_CUDA_VSTD::is_integral, _Up), int> = 0>
_CCCL_NODISCARD _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _Tp ceil_div(const _Tp __a, const _Up __b) noexcept
{
_LIBCUDACXX_DEBUG_ASSERT(__a >= _Tp(0), "cuda::ceil_div: a must be non negative");
_LIBCUDACXX_DEBUG_ASSERT(__b > _Tp(0), "cuda::ceil_div: b must be positive");
_CCCL_ASSERT(__a >= _Tp(0), "cuda::ceil_div: a must be non negative");
_CCCL_ASSERT(__b > _Tp(0), "cuda::ceil_div: b must be positive");
using _UCommon = _CUDA_VSTD::__make_unsigned_t<_CUDA_VSTD::__common_type_t<_Tp, _Up>>;
// Due to the precondition `__a >= 0` we can safely cast to unsigned without danger of overflowing
return static_cast<_Tp>((static_cast<_UCommon>(__a) + static_cast<_UCommon>(__b) - 1) / static_cast<_UCommon>(__b));
Expand Down

0 comments on commit 4500e82

Please sign in to comment.