From fa28fff7d618712a604eb59932293c2f5552a74f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 27 Sep 2026 13:30:57 +0200 Subject: [PATCH] Skip the vector failed-allocation check for VS 2015 with iterator debugging AppVeyor's VS 2015 Debug build terminated in "converting into an existing value": to_json for std::vector default-constructs an array_t first, and VS 2015's std::vector default constructor is noexcept but, with iterator debugging, constructs its proxy through the test's allocator, which throws. Signed-off-by: Niels Lohmann --- tests/src/unit-allocator.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 4e505e9f4..9405cfd38 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -487,9 +487,14 @@ TEST_CASE("a failed allocation leaves the value unchanged") CHECK_THROWS_AS(nlohmann::to_json(j, std::vector {1, 2}), std::bad_alloc&); CHECK(j == "old"); + // with iterator debugging, the default constructor of VS 2015's + // std::vector is noexcept but constructs a proxy with the allocator, + // which terminates when this allocator throws +#if !(defined(_MSC_VER) && _MSC_VER < 1910 && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL > 0) next_construct_fails = true; CHECK_THROWS_AS(nlohmann::to_json(j, std::vector {true, false}), std::bad_alloc&); CHECK(j == "old"); +#endif next_construct_fails = true; CHECK_THROWS_AS(nlohmann::to_json(j, std::map {{"a", 1}}), std::bad_alloc&);