From 740c847ed15b621a29a294bb93872afb5030bba5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 5 Sep 2026 18:26:50 +0200 Subject: [PATCH] Mark parser-callback test lambdas noexcept to fix GCC -Wnoexcept -Werror GCC's libstdc++ std::function move assignment evaluates a noexcept check that invokes a wrapped callable in an unevaluated context; a non-noexcept parser_callback_t lambda then trips -Wnoexcept ("noexcept- expression evaluates to 'false'"), which CI's ci_test_gcc job builds with -Werror. The pre-existing parser_callback_t test lambdas in this file already work around this by declaring themselves noexcept; apply the same fix to the three added lambdas that didn't. Signed-off-by: Niels Lohmann --- tests/src/unit-regression2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index a607d2878..5cf016202 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -1569,7 +1569,7 @@ TEST_CASE("issue #5402 - update(merge_objects=true) overwrites a primitive with TEST_CASE("regression test - parser callback must not lose a duplicate key's prior value") { // a callback that rejects only the scalar value 2 - const json::parser_callback_t drop_value_2 = [](int /*depth*/, json::parse_event_t ev, json & v) + const json::parser_callback_t drop_value_2 = [](int /*depth*/, json::parse_event_t ev, json & v) noexcept { return !(ev == json::parse_event_t::value && v == 2); }; @@ -1583,7 +1583,7 @@ TEST_CASE("regression test - parser callback must not lose a duplicate key's pri SECTION("duplicate key, second value is an object rejected at object_end - prior value is restored") { const json j = json::parse(R"({"a":1,"a":{"x":2}})", - [](int depth, json::parse_event_t ev, json& /*parsed*/) + [](int depth, json::parse_event_t ev, json& /*parsed*/) noexcept { return !(ev == json::parse_event_t::object_end && depth == 1); }); @@ -1593,7 +1593,7 @@ TEST_CASE("regression test - parser callback must not lose a duplicate key's pri SECTION("duplicate key, second value is an array rejected at array_end - prior value is restored") { const json j = json::parse(R"({"a":1,"a":[9,9]})", - [](int depth, json::parse_event_t ev, json& /*parsed*/) + [](int depth, json::parse_event_t ev, json& /*parsed*/) noexcept { return !(ev == json::parse_event_t::array_end && depth == 1); });