Repository navigation
Fix CI on develop after #5585 - #5779
Merged
Merged
Conversation
- test-diagnostics-optimized: -O3 makes GCC's -Winline and -Wsuggest-attribute=pure/const warnings fire with the ci_test_gcc flag set; turn them off for this test. - test-diagnostics-optimized: suppress Clang's -Wexit-time-destructors for the static table in to_json. - Infer: raise pulse-max-disjuncts from 20 to 40. With the default, Pulse loses the stored type in basic_json::replace_value() and reports false null dereferences of get_ptr() results in unit-pointer_access.cpp. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Infer's std::string model keeps the buffer of a moved-from string, so the destroy-and-reconstruct loop in erase(first, last) looks like it destroys a buffer twice. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
With JSON_NOEXCEPTION, JSON_THROW expands to std::abort(), so Clang's -Wunused-parameter breaks test-disabled_exceptions (since #5761). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
clang-tidy (clang-analyzer-security.ArrayBound) flagged it->second for a value not in the table. Use the same fallback as NLOHMANN_JSON_SERIALIZE_ENUM; the test still fails with -Werror=array-bounds on the headers from before #5585. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
- unit-regression2.cpp (#5762): const/auto for the destroy() test values; NOLINT the intended copy in check_destroy_edge_case(). - unit-serialization.cpp (#5774): build the expected strings with += instead of chained operator+ (performance-inefficient-string-concatenation). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This was referenced Oct 7, 2026
gregmarr
reviewed
Oct 7, 2026
| json_test_set_test_options(test-regression1 LINK_LIBRARIES fifo_map_include) | ||
|
|
||
| # GCC's false -Warray-bounds error with JSON_DIAGNOSTICS only shows up when optimizing (#5742) | ||
| # GCC's false -Warray-bounds error with JSON_DIAGNOSTICS only shows up when optimizing (#5742). |
Contributor
There was a problem hiding this comment.
I thought that was fixed now.
Owner
Author
nlohmann
added a commit
that referenced
this pull request
Oct 8, 2026
…5784) * Address review comments on #5775 and #5779 Allow new defaulted parameters and new default arguments in the API stability rules, mention the macro opt-in, and drop the redundant recompile advice. Describe test-diagnostics-optimized as the regression test for the fixed #5742. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Document what counts as a breaking change in the API stability rules Spell out the 3.x compatibility rules in the roadmap: new defaulted parameters, new default arguments, noexcept/constexpr, template parameters, parse and dump results, accepted input, key iteration order, iterator invalidation, implicit conversions, to_json/from_json lookup, json_sax, value_t enumerators, and documented macros, CMake options and headers. Also list std::hash values as not part of the public API, and link the macro overview from the section. Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Ubuntu workflow on develop fails since #5585 (run https://github.com/nlohmann/json/actions/runs/37530611400). This PR fixes the three causes.
ci_test_gcc, ci_test_standards_gcc (14): the new test
test-diagnostics-optimizedis built with-O3. At that level, the-Winlineand-Wsuggest-attribute=purewarnings in theci_test_gccflag set fire on the library's inline functions. The test does not check these warnings, so they are now turned off for this test, together with-Wsuggest-attribute=const. The-O3 -Werror=array-boundscheck for Release build fails when JSON diagnostics enabled #5742 stays. Reproduced with GCC 16.2 ingcc:latest; the test now compiles cleanly.ci_test_clang, ci_test_standards_clang (11): the static table in the test's
to_jsontriggers-Wexit-time-destructors. The warning is now suppressed withDOCTEST_CLANG_SUPPRESS_WARNING, as other tests already do.ci_infer: 7 false
NULLPTR_DEREFERENCEfindings intests/src/unit-pointer_access.cpp, caused by Create a value before giving it its type #5585.basic_json::replace_value()callsdestroy()and thenassert_invariant(). Together they create more paths than Pulse explores by default (pulse-max-disjuncts, 20). Pulse then loses track of the stored type and assumesget_ptr()can return null for a value it just constructed. Removing either call made the findings go away, but the library code stays as is. Instead,.inferconfigraisespulse-max-disjunctsto 40. Checked with Infer 1.3.0 (the CI version) ontest-pointer_access: 7 findings with the default, none with 40.ci_infer:
USE_AFTER_DELETEatinclude/nlohmann/ordered_map.hpp:262(erase(first, last)). This is a false positive: Infer modelsstd::stringas keeping the buffer of a moved-from string, so the loop that destroys and re-creates elements looks like it destroys a buffer twice. It now has an@infer-ignore USE_AFTER_DELETEcomment, the form already used injson.hppandbinary_reader.hpp. A full Infer run withpulse-max-disjuncts40 and without this comment reported only this finding.Two more failures came in with that merge, and both also affect develop:
ci_test_standards_clang (14, libstdcxx), ci_static_analysis_clang (ci_test_clang): with
JSON_NOEXCEPTION,JSON_THROWbecomesstd::abort(), so the parameters ofbinary_writer::throw_on_discarded()(Throw type_error.321 when serializing discarded values to binary formats #5761) are unused and-Wunused-parameterbreakstest-disabled_exceptions. They are now cast tovoid. Develop had not shown this yet because these jobs were cancelled there.ci_cmake_options (ci_test_delete_deprecated_functions): the sax_parse cannot read CBOR that contains tags, including binary values with a subtype written by to_cbor #5676 regression test from Allow SAX parsing of tagged CBOR #5740 calls the deprecated
sax_parse(span_input_adapter&&, ...), whichJSON_DELETE_DEPRECATED_FUNCTIONSdeletes. Those two checks are now skipped in that configuration, using theJSON_TEST_DEPRECATED_FUNCTIONS_DELETEDpattern fromunit-cbor.cpp.ci_clang_tidy: this job had been cancelled on develop, so its findings had piled up:
unit-diagnostics-optimized.cpp(this PR):to_jsonread past the end of its table for a value it did not contain. It now falls back to the first entry, asNLOHMANN_JSON_SERIALIZE_ENUMdoes. The test still fails with-Werror=array-boundson the headers from before Create a value before giving it its type #5585.unit-regression2.cpp(Make basic_json destruction allocation-free and non-recursive #5762):const/autofor thedestroy()test values, and aNOLINTfor the copy thatcheck_destroy_edge_case()makes on purpose.unit-serialization.cpp(Stricter fuzzer checks and boundary-value tests for buffers #5774): the expected strings are built with+=instead of chainedoperator+.clang-tidy 22.1.8 (
silkeh/clang:22, the CI image) was run locally on every test source and now reports nothing.On the previous push (2e4d840),
ci_inferpassed ("No issues found"). It took 81 minutes, against 50 on develop. A local run with the same settings took 52 minutes, so most of the difference is probably runner variance.Develop is merged in (#5740, #5766, #5774-#5777); none of those commits touch the files changed here.
Public API
No breaking changes. The library changes are a comment in
ordered_map.hppand twostatic_cast<void>statements in a private function ofbinary_writer; the rest is CI configuration and tests.Written by Claude Code.
🤖 Generated with Claude Code