From 84c5421644314a301ecb1312bbb4e1ff7e1a729d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 27 Oct 2026 20:31:53 +0100 Subject: [PATCH 1/2] Fix regression1 operator[](json_pointer) test under JSON_NO_THREAD_LOCAL (#5952) The test relies on a copied fifo_map restarting its timestamps. Copying a basic_json does that only on the recursive path; with JSON_NO_THREAD_LOCAL the copy is built member by member and keeps correct timestamps, so the premise was missing and the test failed (ci_test_no_thread_local, MinGW clang). Copy the object_t explicitly to create the state on every path. Signed-off-by: Niels Lohmann --- tests/src/unit-regression1.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp index fae261ebf..b98f2b6f3 100644 --- a/tests/src/unit-regression1.cpp +++ b/tests/src/unit-regression1.cpp @@ -1504,13 +1504,16 @@ TEST_CASE("regression tests 1") // a copied fifo_map restarts its timestamps, so a new key "k" gets // the timestamp of "x": the lookup does not find "k", but emplace() // finds "x" and inserts nothing; the pointer then continues with the - // member of "x", as basic_json::operator[] does + // member of "x", as basic_json::operator[] does. The object_t is + // copied explicitly: copying the my_json would build the object + // member by member (with fresh timestamps) when built with + // JSON_NO_THREAD_LOCAL. const my_json orig = my_json::parse(R"({"x":1})"); const std::array pointers = {{"/k/0", "/k/a/b", "/k/-"}}; for (const char* pointer : pointers) { CAPTURE(pointer) - my_json j = orig; + my_json j(orig.get_ref()); CHECK_THROWS_AS(j[my_json::json_pointer(pointer)], my_json::out_of_range&); CHECK(j.dump() == R"({"x":1})"); } From da83aa92c88aa4bcacc3bc29cef59fec5d257543 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 28 Oct 2026 07:11:04 +0100 Subject: [PATCH 2/2] Reconcile -Weffc++ and readability-redundant-member-init in unit-bson.cpp (#5953) --- tests/src/unit-bson.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index 09321e3d5..8e2d00cbf 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -1311,6 +1311,8 @@ TEST_CASE("BSON declared document size bounds the content") // records the events that a SAX parser receives struct recorder : nlohmann::json_sax { + // GCC's -Weffc++ wants the member initialized in the member initialization list + // NOLINTNEXTLINE(readability-redundant-member-init) std::string events {}; bool null() override