diff --git a/include/xtensor/views/xslice.hpp b/include/xtensor/views/xslice.hpp index d2142fb82..95882f65c 100644 --- a/include/xtensor/views/xslice.hpp +++ b/include/xtensor/views/xslice.hpp @@ -1059,7 +1059,7 @@ namespace xt , m_step(step) { size_type n = stop_val - start_val; - m_size = n / step + (((n < 0) ^ (step > 0)) && (n % step)); + m_size = (n > 0) ^ (step > 0) ? 0 : n / step + static_cast(n % step); } template