diff --git a/cmake/clang_flags.cmake b/cmake/clang_flags.cmake index b3dfa3144..aea17820c 100644 --- a/cmake/clang_flags.cmake +++ b/cmake/clang_flags.cmake @@ -5,8 +5,11 @@ # -Wno-extra-semi-stmt The library uses assert which triggers this warning. # -Wno-padded We do not care about padding warnings. # -Wno-covered-switch-default All switches list all cases and a default case. -# -Wno-unsafe-buffer-usage Otherwise Doctest would not compile. -# -Wno-missing-noreturn We found no way to silence this warning otherwise, see PR #4871 +# -Wno-unsafe-buffer-usage Pervasive: the library's own low-level numeric/buffer code +# (to_chars, serializer, lexer, binary reader/writer, input +# adapters, json_pointer) plus vendored Doctest itself (~208 +# distinct sites measured 2026-07-08 on clang trunk) all use +# raw pointer arithmetic / libc string calls by necessity. set(CLANG_CXXFLAGS -Werror @@ -18,5 +21,4 @@ set(CLANG_CXXFLAGS -Wno-padded -Wno-covered-switch-default -Wno-unsafe-buffer-usage - -Wno-missing-noreturn ) diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 94af90202..920a26adc 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -430,7 +430,7 @@ class wide_string_input_adapter // parsing binary with wchar doesn't make sense, but since the parsing mode can be runtime, we need something here template - std::size_t get_elements(T* /*dest*/, std::size_t /*count*/ = 1) + JSON_HEDLEY_NO_RETURN std::size_t get_elements(T* /*dest*/, std::size_t /*count*/ = 1) { JSON_THROW(parse_error::create(112, 1, "wide string type cannot be interpreted as binary data", nullptr)); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 5c022253a..c083d0b29 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7262,7 +7262,7 @@ class wide_string_input_adapter // parsing binary with wchar doesn't make sense, but since the parsing mode can be runtime, we need something here template - std::size_t get_elements(T* /*dest*/, std::size_t /*count*/ = 1) + JSON_HEDLEY_NO_RETURN std::size_t get_elements(T* /*dest*/, std::size_t /*count*/ = 1) { JSON_THROW(parse_error::create(112, 1, "wide string type cannot be interpreted as binary data", nullptr)); } diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 6f2c70148..2dbb746b0 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -24,7 +24,7 @@ struct bad_allocator : std::allocator template bad_allocator(const bad_allocator& /*unused*/) { } template - void construct(T* /*unused*/, Args&& ... /*unused*/) // NOLINT(cppcoreguidelines-missing-std-forward) + [[noreturn]] void construct(T* /*unused*/, Args&& ... /*unused*/) // NOLINT(cppcoreguidelines-missing-std-forward) { throw std::bad_alloc(); }