Skip to content

Commit

Permalink
Merge pull request #246 from wmaxey/bugfix_msvc_ICE
Browse files Browse the repository at this point in the history
Fix an ICE on MSVC 14.3X
  • Loading branch information
crtrott authored Mar 14, 2023
2 parents cf374bc + 38c7e8d commit b31a635
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions include/experimental/__p0009_bits/extents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,20 @@ static constexpr std::false_type _check_compatible_extents(
std::false_type, std::integer_sequence<size_t, Extents...>, std::integer_sequence<size_t, OtherExtents...>
) noexcept { return { }; }

// This helper prevents ICE's on MSVC.
template <size_t Lhs, size_t Rhs>
struct _compare_extent_compatible : std::integral_constant<bool,
Lhs == dynamic_extent ||
Rhs == dynamic_extent ||
Lhs == Rhs>
{};

template <size_t... Extents, size_t... OtherExtents>
static std::integral_constant<
bool,
_MDSPAN_FOLD_AND(
(
Extents == dynamic_extent
|| OtherExtents == dynamic_extent
|| Extents == OtherExtents
_compare_extent_compatible<Extents, OtherExtents>::value
) /* && ... */
)
>
Expand Down
2 changes: 1 addition & 1 deletion include/experimental/__p0009_bits/layout_left.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class layout_left::mapping {
)
_MDSPAN_HOST_DEVICE
constexpr index_type operator()(Indices... idxs) const noexcept {
return __compute_offset(__rank_count<0, extents_type::rank()>(), idxs...);
return __compute_offset(__rank_count<0, extents_type::rank()>(), static_cast<index_type>(idxs)...);
}


Expand Down
2 changes: 1 addition & 1 deletion include/experimental/__p0009_bits/layout_right.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class layout_right::mapping {
)
_MDSPAN_HOST_DEVICE
constexpr index_type operator()(Indices... idxs) const noexcept {
return __compute_offset(__rank_count<0, extents_type::rank()>(), idxs...);
return __compute_offset(__rank_count<0, extents_type::rank()>(), static_cast<index_type>(idxs)...);
}

MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { return true; }
Expand Down
2 changes: 1 addition & 1 deletion include/experimental/__p0009_bits/layout_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ struct layout_stride {
)
MDSPAN_FORCE_INLINE_FUNCTION
constexpr index_type operator()(Indices... idxs) const noexcept {
return __impl::_call_op_impl(*this, static_cast<index_type>(idxs)...);
return static_cast<index_type>(__impl::_call_op_impl(*this, static_cast<index_type>(idxs)...));
}

MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { return true; }
Expand Down

0 comments on commit b31a635

Please sign in to comment.