-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Labels
confirmeddocumentationsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
- What is the issue you have?
- crash when traversing over
items()
of temporary json objects - sometimes got null of
pair.value()
(https://godbolt.org/z/TTQFHW)
- Please describe the steps to reproduce the issue. Can you provide a small but working code example?
const auto obj = nlohmann::json::parse(R"({
"key1": 0.1,
"key2": 0.2
})");
auto rvalue = [&]() -> nlohmann::json { return obj; };
for (const auto& pair : rvalue().items()) {
std::cout << pair.key() << ": " << pair.value() << "\n"; // crash
}
auto crvalue = [&]() -> const nlohmann::json { return obj; };
for (const auto& pair : crvalue().items()) {
std::cout << pair.key() << ": " << pair.value() << "\n"; // crash
}
- What is the expected behavior?
pair.value()
returns0.1
or0.2
- no crash
- And what is the actual behavior instead?
- crash on my linux machine:
json.hpp:14028: void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType&, bool, bool, unsigned int, unsigned int) [with BasicJsonType = nlohmann::basic_json<>]: Assertion ‘false' failed.
pair.value()
returns null on Compiler Explorer. (https://godbolt.org/z/TTQFHW)
- Which compiler and operating system are you using? Is it a supported compiler?
- linux/centos
- gcc 6.2
- Did you use a released version of the library or the version from the
develop
branch?
kongr45gpen
Metadata
Metadata
Assignees
Labels
confirmeddocumentationsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation