Skip to content

Fix compiler warnings on develop from the API performance stack - #5858

Merged
nlohmann merged 1 commit into
developfrom
fix-json-pointer-sign-conversion
Oct 15, 2026
Merged

nlohmann merged 1 commit into
developfrom
fix-json-pointer-sign-conversion

Conversation

@nlohmann

Copy link
Copy Markdown
Owner

Most of the API performance stack (#5832–#5842) was merged while its CI runs were cancelled. On develop, the -Werror builds now fail, so every open PR that merges develop fails ~60 jobs (seen on #5826). This PR fixes every warning I could reproduce locally with the CI flags from cmake/gcc_flags.cmake and cmake/clang_flags.cmake (GCC 16.2 and Apple clang 21, all tests/src/unit-*.cpp at C++11/17/20):

File From Warning Fix
detail/json_pointer.hpp #5836 GCC -Wsign-conversion: size_t += int static_cast<std::size_t>(c == '/')
detail/input/binary_reader.hpp #5839 GCC -Wconversion: char_int_type passed as char bson_unsupported_type_error() takes char_int_type
json.hpp #5838 clang -Wdocumentation: @throw without a description describe when it throws
detail/string_escape.hpp #5836 clang -Wdocumentation: escape_into() was inserted between escape() and its doc comment, so @return documented a void function moved the doc comment back to escape(), short comment for escape_into()
tests/src/unit-diagnostics.cpp #5832 clang -Wnrvo in a lambda explicit -> J return type
tests/src/unit-to_json-rvalue.cpp #5837 GCC -Wnoexcept (C++20), clang -Wunneeded-member-function noexcept constructor; the unused move assignment is deleted

Verified locally: no errors left from either compiler under the CI warning flags (apart from macOS-only int64_t == long long artifacts in old tests), and unit-json_pointer, unit-diagnostics, unit-to_json-rvalue, unit-bson and unit-algorithms pass. make amalgamate is clean. CI may still find issues on other platforms (MSVC, clang-tidy, older compilers) that I couldn't reproduce here.

Public API

No breaking changes. The only change to a declaration is the parameter type of the private binary_reader::bson_unsupported_type_error(). Everything else is comments and tests.


Written by Claude Code on behalf of Niels Lohmann.

🤖 Generated with Claude Code

These PRs were merged while their CI runs were cancelled, so the warnings
went unnoticed. All of them fail the -Werror builds:

- json_pointer.hpp (#5836): size_t += int under GCC -Wsign-conversion
- binary_reader.hpp (#5839): char_int_type passed as char under GCC
  -Wconversion
- json.hpp (#5838): @throw without a description under clang
  -Wdocumentation
- string_escape.hpp (#5836): escape_into() was inserted between escape()
  and its documentation, so the @return was attached to a void function
- unit-diagnostics.cpp (#5832): clang -Wnrvo in a lambda without an
  explicit return type
- unit-to_json-rvalue.cpp (#5837): GCC -Wnoexcept (C++20) and clang
  -Wunneeded-member-function on the test type

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@nlohmann nlohmann added this to the Release 3.13.0 milestone Oct 15, 2026
@nlohmann
nlohmann merged commit 4da73dc into develop Oct 15, 2026
4 of 167 checks passed
@nlohmann
nlohmann deleted the fix-json-pointer-sign-conversion branch October 15, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant