Skip to content

Commit

Permalink
Add explicit casts to workaround nvcc bug.
Browse files Browse the repository at this point in the history
nvcc is failing on evaluating this code in a constant expression
without the explicit casts.

nvbug/3145483
  • Loading branch information
jrhemstad committed Oct 6, 2020
1 parent 5e43aae commit 404e120
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libcxx/include/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,8 @@ constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
_LIBCUDACXX_INLINE_VISIBILITY
constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
{
const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
// casts are required to work around nvcc bug 3145483
const int __wdu = static_cast<int>(__lhs.c_encoding())- static_cast<int>(__rhs.c_encoding());
const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
return days{__wdu - __wk * 7};
}
Expand Down

0 comments on commit 404e120

Please sign in to comment.