Skip to content

Initialization different between gcc/clang #2311

@rpav

Description

@rpav

What is the issue you have?

Initialization seems to differ between clang and gcc (have not yet tried MSVC):

json j{json::object()};

std::cout << j << std::endl; 
// GCC:   [{}]
// clang: {}

I.e., in gcc this creates an array with an object as its first element; in clang it creates an object.

Please describe the steps to reproduce the issue.

Running example: https://godbolt.org/z/7r76TE

Can you provide a small but working code example?

As above.

What is the expected behavior?

Consistent initialization between compilers for the same code.

And what is the actual behavior instead?

Different values per compiler.

Which compiler and operating system are you using?

  • Compiler: clang 10, gcc 10.1
  • Operating system: Linux
  • std: c++17

Which version of the library did you use?

  • latest release version 3.7.3
  • other release - please state the version: 3.6.0, 3.8.0, whatever "trunk" is on godbolt
  • the develop branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugsolution: 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