From a3c2b0897ec9518781becc5176122991c9ad8ce4 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 28 Sep 2026 04:19:20 +0200 Subject: [PATCH] Fix -Weffc++ errors in the #5198 locale test GCC's -Weffc++ (an error in ci_test_gcc and ci_test_standards_gcc) rejected LocaleSwitchingSax: it has a pointer data member but does not declare its copy operations, and its vectors are not initialized in the member initializer list. Store the locale name as a std::string and give the vectors brace initializers, like SaxEventLogger in unit-deserialization.cpp. 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 b83e63bde..9f62fc0ca 100644 --- a/tests/src/unit-locale-cpp.cpp +++ b/tests/src/unit-locale-cpp.cpp @@ -236,7 +236,7 @@ struct LocaleSwitchingSax final: public nlohmann::json_sax } bool start_array(std::size_t /*val*/) override { - switched = std::setlocale(LC_NUMERIC, locale_after_open) != nullptr; + switched = std::setlocale(LC_NUMERIC, locale_after_open.c_str()) != nullptr; return true; } bool end_array() override @@ -248,10 +248,10 @@ struct LocaleSwitchingSax final: public nlohmann::json_sax return false; } - const char* locale_after_open; + std::string locale_after_open; bool switched = false; - std::vector values; - std::vector strings; + std::vector values {}; // NOLINT(readability-redundant-member-init) + std::vector strings {}; // NOLINT(readability-redundant-member-init) }; } // namespace