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

Inconsistent Constructor (GCC vs. Clang) #1381

Closed
anthonyclark-as opened this issue Dec 4, 2018 · 3 comments
Closed

Inconsistent Constructor (GCC vs. Clang) #1381

anthonyclark-as opened this issue Dec 4, 2018 · 3 comments
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@anthonyclark-as
Copy link

anthonyclark-as commented Dec 4, 2018

  • What is the issue you have?

Different results between compilers.

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

https://wandbox.org/permlink/hFofcAQwaX2JMBQ6

The link is for clang 7.0. If you do the same config (no boost, add -I. in the options, and select GCC 8.2.0), you'll get different output.

  • What is the expected behavior?

The output should be the same between both compilers, right?

  • And what is the actual behavior instead?

Constructing my member variable from a json const & in gcc, encapsulates the internal object into an array.

GCC 8.2.0 and Clang 7.0. Not sure which compiler is yielding proper results.

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

Release, 3.4.0.

No compilation error.

@anthonyclark-as
Copy link
Author

To append the issue...

CLANG 7.0 output

{
    "f": 1.32,
    "x": 567
}

GCC 8.2.0 output:

[
    {
        "f": 1.32,
        "x": 567
    }
]

@anthonyclark-as
Copy link
Author

anthonyclark-as commented Dec 4, 2018

With GCC, moving the m_doc initialization OUT OF the member initializer list makes this mirror clang. I'll see if I can find a solution / reason this is happening.

When the GCC compiled binary hits the member initialization, it goes into a json_ref constructor. Clang seems to be avoiding this at all optimization levels. I can't seem to get GDB to breakpoint on the member initializer...

@nlohmann
Copy link
Owner

nlohmann commented Dec 4, 2018

Duplicate of #1359.

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Dec 4, 2018
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