Open xamix opened 1 year ago
I can confirm the issue.
If I understood the code correctly, as of json k(j);
the invariant is invalid for instance j
due to function insert(it, it)
missing a call to set_parents()
after this line of code: https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp#L3408
Provided I got the meaning of the statement, during insertion, the properties are basically copied (inserted) to the underlying data structure ObjectType
(being std::map
for default nlohmann::json) and the copies keep the original parent (as no set_parents()
is called during insertion).
Description
Hi,
I have activated the JSON_DIAGNOSTICS=1 globally in my project and ASSERTION are now fired at runtime. I tested it on with 3.10.5 and then with latest release 3.11.2.
I have done a minimal example to reproduce the assertion (see minimal code example below)
Is there something wrong with my code?
Reproduction steps
Run the minimal code example below
Expected vs. actual results
No ASSERTION should be triggered since without the JSON_DIAGNOSTICS enabled, all seem to work without any memory issues
Minimal code example
Error messages
Compiler and operating system
Clang-10 on Ubuntu 20.04
Library version
3.11.2
Validation
develop
branch is used.