From efea5cbe43db84c86b1732bfb70f52d7412a995d Mon Sep 17 00:00:00 2001 From: Stephan Lachnit Date: Mon, 18 Nov 2024 12:02:18 +0100 Subject: [PATCH] Cast to index_type before checking negative indicies in at() --- include/experimental/__p0009_bits/mdspan.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/experimental/__p0009_bits/mdspan.hpp b/include/experimental/__p0009_bits/mdspan.hpp index 0bac391c..2100492a 100644 --- a/include/experimental/__p0009_bits/mdspan.hpp +++ b/include/experimental/__p0009_bits/mdspan.hpp @@ -452,8 +452,8 @@ class mdspan ) MDSPAN_FORCE_INLINE_FUNCTION constexpr bool __is_index_oor(SizeType index, index_type extent) const noexcept { // Check for negative indices - if constexpr(std::is_signed_v) { - if(index < 0) { + if constexpr (std::is_signed_v) { + if (static_cast(index) < 0) { return true; } }