Fix incomplete-type error in set_parents with ordered_json#5167
Merged
nlohmann merged 1 commit intoMay 14, 2026
Merged
Conversation
When iteration_proxy_value<iter_impl<ordered_json>> appears in a context
that requires it to be complete (function or lambda parameter), the
compiler instantiates basic_json<ordered_map> and walks into
set_parents(iterator, typename iterator::difference_type)
while iterator is still incomplete, failing with "invalid use of
incomplete type".
basic_json::difference_type is already std::ptrdiff_t, so just naming
the underlying type directly avoids the dependent lookup. Behavior and
ABI are unchanged. This was the approach suggested in the issue thread.
Added a regression case in unit-ordered_json.cpp using the same trigger
pattern (lambda parameter naming the proxy type).
Fixes nlohmann#3732
Signed-off-by: Akhilesh Arora <akhildawra@gmail.com>
Owner
|
Thanks! |
GhostVaibhav
pushed a commit
to GhostVaibhav/json
that referenced
this pull request
May 19, 2026
…5167) When iteration_proxy_value<iter_impl<ordered_json>> appears in a context that requires it to be complete (function or lambda parameter), the compiler instantiates basic_json<ordered_map> and walks into set_parents(iterator, typename iterator::difference_type) while iterator is still incomplete, failing with "invalid use of incomplete type". basic_json::difference_type is already std::ptrdiff_t, so just naming the underlying type directly avoids the dependent lookup. Behavior and ABI are unchanged. This was the approach suggested in the issue thread. Added a regression case in unit-ordered_json.cpp using the same trigger pattern (lambda parameter naming the proxy type). Fixes nlohmann#3732 Signed-off-by: Akhilesh Arora <akhildawra@gmail.com> Signed-off-by: Vaibhav Sharma <48472541+GhostVaibhav@users.noreply.github.com>
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.
Fixes #3732 (label: confirmed).
If you name
detail::iteration_proxy_value<detail::iter_impl<ordered_json>>where it has to be complete (function or lambda parameter), the compile blows up:The cascade is
proxy -> iter_impl<ordered_json> -> basic_json<ordered_map>, and duringbasic_json's instantiation the compiler hitsset_parents(iterator, typename iterator::difference_type)beforeiteratoris complete.basic_json::difference_typeis alreadystd::ptrdiff_t, so just using the underlying type directly avoids the dependent lookup. Same behavior, no ABI change. This was suggested in the issue thread.Added a regression case in
tests/src/unit-ordered_json.cpp(lambda parameter naming the proxy type — same trigger as the minimal repro). Full localctestrun passes (102/102).The frozen ABI snapshot at
tests/abi/include/nlohmann/json_v3_10_5.hppis intentionally left alone.single_include/nlohmann/json.hppupdated to match).