diff --git a/include/xtensor/views/xslice.hpp b/include/xtensor/views/xslice.hpp index d2142fb82..2de2d77a6 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 = std::max(n / step + (((n < 0) ^ (step > 0)) && (n % step)), size_type(0)); } template