json
json copied to clipboard
Unexpected array when initializing a json const& on gcc 4.8.5 using uniform syntax
Minimal example:
#include "json.hpp" // 3.9.1
#include <cassert>
#include <iostream>
using namespace nlohmann;
using namespace std;
int main()
{
json const j = "{\"key\": null}"_json;
assert(j.is_object());
json const& k{j.at("key")};
cout << k << endl;
assert(k.is_null());
}
Fails on gcc 4.8.5 with -std=c++0x:
[null]
minimal: minimal.cpp:14: int main(): Assertion `k.is_null()' failed.
Note that k refers to an array, so at() has made a copy though j is const. Don't know if you keep track of that copy via some mutable or if there is a segfault ahead because of a dangling reference.
Passes on more recent gcc.
Duplicate of #2311.
Duplicate of #2311.
Sure? This affects only older gcc. It really messes badly with the reference initialization.