From 633de8e44bbbc29383d72f8c920343ea5d1eaa21 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 28 Sep 2026 22:20:43 +0200 Subject: [PATCH] Fix CI: clang-tidy and GCC -Wnoexcept in the locale test (#5613) #5597 was merged before all of its CI jobs had run, and two of them fail on develop now, and so on every pull request: - ci_clang_tidy: cert-err33-c for the two std::setlocale(LC_NUMERIC, "C") calls whose result was discarded. Check the result, like the other resets in the file. - ci_test_standards_gcc (20) with GCC 16: -Wnoexcept for the two parser callbacks, which cannot throw but were not declared noexcept. Signed-off-by: Niels Lohmann --- tests/src/unit-locale-cpp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/unit-locale-cpp.cpp b/tests/src/unit-locale-cpp.cpp index 9f62fc0ca..14f743a66 100644 --- a/tests/src/unit-locale-cpp.cpp +++ b/tests/src/unit-locale-cpp.cpp @@ -309,7 +309,7 @@ TEST_CASE("locale changes between lexer construction and number conversion (#519 // DOM parsing with a callback { bool switched = false; - const auto cb = [&](int /*depth*/, json::parse_event_t event, json& /*parsed*/) + const auto cb = [&](int /*depth*/, json::parse_event_t event, json& /*parsed*/) noexcept { if (event == json::parse_event_t::array_start) { @@ -327,7 +327,7 @@ TEST_CASE("locale changes between lexer construction and number conversion (#519 // a long double goes through std::strtold unless std::from_chars supports it { bool switched = false; - const auto cb = [&](int /*depth*/, long_double_json::parse_event_t event, long_double_json& /*parsed*/) + const auto cb = [&](int /*depth*/, long_double_json::parse_event_t event, long_double_json& /*parsed*/) noexcept { if (event == long_double_json::parse_event_t::array_start) { @@ -343,7 +343,7 @@ TEST_CASE("locale changes between lexer construction and number conversion (#519 } } - std::setlocale(LC_NUMERIC, "C"); + CHECK(std::setlocale(LC_NUMERIC, "C") != nullptr); } TEST_CASE("locale with a multi-byte decimal point") @@ -383,5 +383,5 @@ TEST_CASE("locale with a multi-byte decimal point") MESSAGE("no locale with a multi-byte decimal point is usable"); } - std::setlocale(LC_NUMERIC, "C"); + CHECK(std::setlocale(LC_NUMERIC, "C") != nullptr); }