From 27bb251d17ee2b5acb0ac7c5e271db95a3daacd0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 09:52:13 +0000 Subject: [PATCH] Return std::size_t from the hash helper in the ordered_json test MSVC (Win32) rejected the implicit conversion of the unsigned long long product to the 32-bit std::size_t (C4244 as an error). Also note when JSON_NO_THREAD_LOCAL is set in the regression test. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01N5NasAgbDGG28MqXjQvLqp Signed-off-by: Claude --- tests/src/unit-ordered_json.cpp | 5 +++-- tests/src/unit-regression1.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/src/unit-ordered_json.cpp b/tests/src/unit-ordered_json.cpp index 2c72b3e8c..8c07ffa16 100644 --- a/tests/src/unit-ordered_json.cpp +++ b/tests/src/unit-ordered_json.cpp @@ -534,9 +534,10 @@ TEST_CASE("object_key_index") // the hashes are not distinct on purpose: elements with the same // hash are told apart by the caller - const auto hash_of = [](std::size_t position) + const auto hash_of = [](std::size_t position) -> std::size_t { - return (position % 50) * 0x9E3779B97F4A7C15ull; + // truncated to 32 bits where std::size_t is that small + return static_cast((position % 50) * 0x9E3779B97F4A7C15ull); }; std::vector hashes; diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp index 9338365c8..53f501f07 100644 --- a/tests/src/unit-regression1.cpp +++ b/tests/src/unit-regression1.cpp @@ -1555,6 +1555,7 @@ TEST_CASE("regression tests 1") { my_json j = make(); #ifdef JSON_NO_THREAD_LOCAL + // (set by the user, or by the library for clang with MinGW) // the objects below the outermost one are not copied by their // object_t here, but member by member, which keeps their // timestamps correct: "c" is not mistaken for "b" and is inserted