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

compile error when using gcc14 #4657

Open
2 tasks
liwenhui-soul opened this issue Feb 20, 2025 · 2 comments · May be fixed by #4704
Open
2 tasks

compile error when using gcc14 #4657

liwenhui-soul opened this issue Feb 20, 2025 · 2 comments · May be fixed by #4704

Comments

@liwenhui-soul
Copy link

liwenhui-soul commented Feb 20, 2025

Description

version: 3.11.3
gcc version: 14.2.0

const char json_string[] = R"({"string":"Hello World","int":42,"double":3.14,"array":[1,2,"3",4.0,null],"bool":true,"object":{"string":"Hello World","int":42,"double":3.14,"array":[1,2,"3",4.0,null],"bool":true}})";

auto root = nlohmann::json::parse(json_string);

Reproduction steps

Compiling with -O2 will cause the following error,but compiling without -O2 succeeds.

Expected vs. actual results

Image

Minimal code example

const char json_string[] = R"({"string":"Hello World","int":42,"double":3.14,"array":[1,2,"3",4.0,null],"bool":true,"object":{"string":"Hello World","int":42,"double":3.14,"array":[1,2,"3",4.0,null],"bool":true}})";

auto root = nlohmann::json::parse(json_string);

Error messages

Compiler and operating system

ubuntu-22.04

Library version

3.11.3

Validation

@Schoppenglas
Copy link

Working fine, see https://godbolt.org/z/MToMq5nE5

I am just wondering. You are stating, that you are using gcc14.1 but error message shows gcc14.2. Just a typo?

@liwenhui-soul
Copy link
Author

liwenhui-soul commented Feb 21, 2025

Working fine, see https://godbolt.org/z/MToMq5nE5

I am just wondering. You are stating, that you are using gcc14.1 but error message shows gcc14.2. Just a typo?

Sorry, I didn't make it clear. To reproduce the issue, first add #define JSON_DIAGNOSTICS 1 before the include statements. Secondly, the compilation flags should be -O2 -Wall -Werror -DNDEBUG. The gcc version is 14.2.0
Please try again in https://godbolt.org/z/ve9acMWPn

@yehudamber yehudamber linked a pull request Mar 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants