nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
42.01k stars 6.63k forks source link

Test suite does not compile with C++20 and Clang 17 #3979

Open nlohmann opened 1 year ago

nlohmann commented 1 year ago

Description

With Clang 16, the test suite could be compiled with C++20, see https://github.com/nlohmann/json/actions/runs/4364410245/jobs/7631709068

When switching to Clang 17, there is an error: https://github.com/nlohmann/json/actions/runs/4409390311/jobs/7725631191#step:7:68

Reproduction steps

Compile the test suite with Clang 17 and C++20 standard enabled.

Expected vs. actual results

Expected: Test suite compiles.

Actual: Error message:

json/tests/src/unit-constructor1.cpp:282:34: error: invalid operands to binary expression ('Expression_lhs<const basic_string<char, char_traits<char>, allocator<char>> &>' and 'const value_type' (aka 'const nlohmann::basic_json<>'))
            CHECK(std::get<2>(t) == j[2]);
            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

Minimal code example

No response

Error messages

json/tests/src/unit-constructor1.cpp:282:34: error: invalid operands to binary expression ('Expression_lhs<const basic_string<char, char_traits<char>, allocator<char>> &>' and 'const value_type' (aka 'const nlohmann::basic_json<>'))
            CHECK(std::get<2>(t) == j[2]);
            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

Compiler and operating system

Clang 17, Ubuntu

Library version

develop

Validation

nlohmann commented 1 year ago

See https://github.com/nlohmann/json/pull/3978 where I tried to fix the CI by setting some compile flags.