From d7a753487226c5e856547af2a583d4aefb0e4160 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 2 Nov 2026 19:12:26 +0100 Subject: [PATCH] Tests: skip the parse() allocation sweep with MSVC iterator debugging With _ITERATOR_DEBUG_LEVEL > 0 (MSVC STL debug builds, clang-cl), containers allocate inside noexcept functions, so a failing allocation terminates the program: "test case CRASHED: Terminate handler called" in the sax_parse subcase of #5985. The sweep test of #6000 has the same guard. Signed-off-by: Niels Lohmann --- tests/src/unit-allocator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index e1dee5509..e3c432ff0 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -1026,7 +1026,10 @@ TEST_CASE("insert() provides its documented exception guarantees (#5986)") } #endif -#if !defined(JSON_NOEXCEPTION) +// the no-exceptions CI job has no std::bad_alloc to catch; with iterator +// debugging (MSVC STL debug builds) containers allocate inside noexcept +// functions, so failing an allocation there terminates the program +#if !defined(JSON_NOEXCEPTION) && !(defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL > 0) namespace { // the allocation numbered sweep_fail_at (counted from 1) throws; 0 never fails