From b8f8ac5cf0899c31cf384196f2945d2234926412 Mon Sep 17 00:00:00 2001 From: Roger Pawlowski Date: Fri, 24 Jul 2026 19:25:14 -0400 Subject: [PATCH] Fix inverted NDEBUG logic in mdspan precondition checking MDSPAN_IMPL_CHECK_PRECONDITION defaulted to enabled when NDEBUG was defined (Release builds) and disabled when NDEBUG was undefined (Debug builds) -- backwards from the usual assert()/NDEBUG convention. As a result, every View/DynRankView mapping construction paid for O(rank) overflow-checked multiplications in optimized builds, causing a large performance regression relative to the legacy View implementation (observed ~20x slower DynRankView construction in a Release build). Swap the branches so precondition checks are enabled for debug builds and disabled for release builds, matching normal convention. Signed-off-by: Roger Pawlowski Assisted-by: Claude --- include/experimental/__p0009_bits/macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/experimental/__p0009_bits/macros.hpp b/include/experimental/__p0009_bits/macros.hpp index c15cfcbc..9379c0c9 100644 --- a/include/experimental/__p0009_bits/macros.hpp +++ b/include/experimental/__p0009_bits/macros.hpp @@ -152,7 +152,7 @@ MDSPAN_FUNCTION inline void default_precondition_violation_handler(const char* c #endif #ifndef MDSPAN_IMPL_CHECK_PRECONDITION - #ifndef NDEBUG + #ifdef NDEBUG #define MDSPAN_IMPL_CHECK_PRECONDITION 0 #else #define MDSPAN_IMPL_CHECK_PRECONDITION 1