Skip to content

Uniform initialization from another json object differs between gcc and clang. #985

Closed

Description

@dsiroky

Construction behaves differently with gcc 7.2 and clang 5.

Code to reproduce:

auto j1{nlohmann::json::parse("5")};
auto j2 = nlohmann::json::parse("5");
std::cout << j1.is_array() << '\n';
std::cout << j2.is_array() << '\n';

gcc prints:
1
0

clang prints:
0
0

Both are nlohmann::json instances however j1 has an array wrapped around in gcc.

Activity

  1. theodelrieu commented on Feb 27, 2018

    @theodelrieu
    Contributor

    IIRC the auto i{2} form has been fixed in C++17, before it would deduce to std::initializer_list instead of int.

    I guess this is the same thing here. If you enable more warnings you should see Clang tell you something like "the meaning of this initialization will change in the future".

    My recommendation would be to not use it at all, uniform initialization is quite borken :/

  2. nlohmann commented on Feb 28, 2018

    @nlohmann
    Owner

    I fear there is nothing we can do about this. :-/

  3. added
    solution: wontfixthe issue will not be fixed (either it is impossible or deemed out of scope)
    on Feb 28, 2018
  4. added
    solution: proposed fixa fix for the issue has been proposed and waits for confirmation
    and removed
    solution: wontfixthe issue will not be fixed (either it is impossible or deemed out of scope)
    on May 8, 2026
  5. added this to the Release 3.12.1 milestone on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    solution: proposed fixa fix for the issue has been proposed and waits for confirmation

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions