From f66897e97864122ae76167ce75a1b6b61d8c25c0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 5 Sep 2026 21:58:12 +0200 Subject: [PATCH] Fix -Werror=unused-result on json::from_cbor() in the 408 regression test from_cbor() is [[nodiscard]]; CHECK_THROWS_AS() otherwise discards its result, which GCC flags under -Werror. Assign to a throwaway json, as the rest of the suite already does for from_cbor()/from_msgpack(). Signed-off-by: Niels Lohmann --- tests/src/unit-regression2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index d6cde9971..6bec0ad3a 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -1661,7 +1661,8 @@ TEST_CASE("regression test - excessive binary container size honors allow_except // declared length of 2^63 before it ever reaches the check this test // targets, with different (but equally valid, and already correct) // wording -- see unit-cbor.cpp for coverage of that message. - CHECK_THROWS_AS(json::from_cbor(cbor), json::out_of_range); + json _; + CHECK_THROWS_AS(_ = json::from_cbor(cbor), json::out_of_range); // regression guard: a genuinely truncated CBOR input must remain discarded CHECK(json::from_cbor(std::vector {0x9b, 0, 0, 0, 0, 0, 0, 0, 0x02}, true, false).is_discarded());