Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json.exception.type_error.305 with GCC 4.9 when using C++ {} initializer #1458

Closed
ibc opened this issue Jan 26, 2019 · 1 comment
Closed
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@ibc
Copy link

ibc commented Jan 26, 2019

  • What is the issue you have?

Code that runs in OSX with clang compiler fails in Linux Debian with gcc 4.9.2.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

This simple code:

json data{ json::object() };
// or
json data{ json::value_t::object };

data["foo"] = 1234;
  • What is the expected behavior?

It works in OSX with clang. IMHO it's supposed to work in Linux. The {} initializer is supposed to be valid.

  • And what is the actual behavior instead?

It crashes with:

[json.exception.type_error.305] cannot use operator[] with a string argument with array

It works with clang: Apple LLVM version 10.0.0 (clang-1000.11.45.5) in OSX.
It fails in Linux Debian with gcc 4.9.2

  • Did you use a released version of the library or the version from the develop branch?

No. Using 3.5.0.

Important:

It works this way:

json data = json::object();
// or
json data = json::value_t::object;
// or
json data(json::value_t::object);
// or
json data(json::object());

data["foo"] = 1234;

So it looks like, when in gcc, the { } initializer is being interpreted as an array, am I right? Is this expected behavior?

@ibc ibc changed the title json.exception.type_error.305 with GCC 4.9 when using {} initializer json.exception.type_error.305 with GCC 4.9 when using C++ {} initializer Jan 26, 2019
@nlohmann
Copy link
Owner

Duplicate of #1359.

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead
Projects
None yet
Development

No branches or pull requests

2 participants