Skip to content

fix inner_active_ test in variant handler's on_array_end - #1203

Open
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:variant-array-end-inner-active
Open

Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:variant-array-end-inner-active

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

Debug build, parse_into into std::variant<X, int> from {"z":[[0]]}:

Assertion failed: (object_depth_ > 0), function on_object_end, file parse_into.hpp, line 1038.

inner_active_ in the variant handler is an int initialised to -1, and every other test of it uses < 0, as do the tuple and described-class handlers that share that convention. on_array_end tests !inner_active_, which is true for alternative 0 and false when no alternative is selected, so while the first alternative is active the closing bracket of its own array is diverted to signal_end instead of being forwarded to it.

Release build, same revision:

variant<vector<vector<int>>,int>   [[1,2]]       accepted, parses to []
variant<vector<vector<int>>,int>   [[1],[2]]     error::exhausted_variants
variant<X,int>                     {"z":[[0]]}   accepted, X default-constructed

The third line is the one that bites. ignoring_handler never receives the array_end that would balance its depth counters, so they wrap, the described-class handler stays pinned on the ignore slot, and seen_ stops being updated; X's three required members are all absent and the document is still accepted. With inner_active_ < 0 the three cases give [[1,2]], [[1],[2]] and error::exhausted_variants.

Tests added to testVariant cover a nested-array alternative and the described-struct case. They fail on develop.

@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1203.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-10-01 07:20:00 UTC

@cppalliance-bot

Copy link
Copy Markdown

GCOVR code coverage report https://1203.json.prtest2.cppalliance.org/gcovr/index.html
LCOV code coverage report https://1203.json.prtest2.cppalliance.org/genhtml/index.html
Coverage Diff Report https://1203.json.prtest2.cppalliance.org/diff-report/index.html

Build time: 2026-10-01 07:47:17 UTC

@cppalliance-bot

Copy link
Copy Markdown

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.

2 participants