From 11e91aa2c5b31cbb4acae2c45a903eba2c3518ae Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 8 Sep 2026 20:15:31 +0200 Subject: [PATCH] Use utils::ignore_return_value() for the issue #1445 dump() discard too Addresses review feedback from @gregmarr on PR #5477: this call site was still using the older "capture in a variable, then (void) it" pattern from before this PR introduced utils::ignore_return_value(), instead of the helper now used at every other discarded-nodiscard-result call site this PR touches. Signed-off-by: Niels Lohmann --- tests/src/unit-regression2.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 2d904707e..6c30e3503 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -641,12 +641,8 @@ TEST_CASE("regression tests 2") s += static_cast(i); } dump_test["1"] = s; - // dump() is nodiscard; this only checks that dumping does not throw/crash. - // A (void) cast on the call itself does not suppress GCC's warning for the - // GNU warn_unused_result attribute (unlike a real C++17 [[nodiscard]]), so - // capture the result in a variable and discard that instead. - auto dump_result = dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace); - (void)dump_result; + // dump() is nodiscard; this only checks that dumping does not throw/crash + utils::ignore_return_value(dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace)); } }