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

Tests failing when compiling with c++20 #3207

Closed
vakokako opened this issue Dec 22, 2021 · 5 comments · Fixed by #3446
Closed

Tests failing when compiling with c++20 #3207

vakokako opened this issue Dec 22, 2021 · 5 comments · Fixed by #3446
Assignees
Labels
kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@vakokako
Copy link

When built with c++20, on some platforms test unit-comparison.cpp:213 fails.

The comparison of c++17 vs c++20 behavior can be seen here: godbolt.

@nlohmann
Copy link
Owner

Thanks for reporting! We're running the tests on macOS (Xcode 12.4) and Ubuntu (Clang 14.0.0 and GCC 11.1.0) without problems. On Godbolt, the behavior only differs in GCC 11.2. I'll check to get that compiler.

@NeroBurner
Copy link

I've tried to run the tests with g++11.2.0 and clang 13.0.0 in C++20 mode. g++ fails as described, but clang works

I suspect it to be the default comparisons by the new spaceship operator

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2085r0.html

The mentioned paper isn't implemented in Clang 13 yet (but should be in Clang 14 🤔 ). It's the last mentioned paper in the table when searching for Consistent comparison (operator<=>)

https://clang.llvm.org/cxx_status.html#cxx20

Consistent comparison Clang implementation status

@gregmarr
Copy link
Contributor

gregmarr commented Feb 3, 2022

@NeroBurner Discussed in #3138

@nlohmann nlohmann added the state: help needed the issue needs help to proceed label Feb 5, 2022
@nlohmann
Copy link
Owner

nlohmann commented Apr 25, 2022

@falbrechtskirchinger What is needed beyond #3379 to fix this? #3446?

@falbrechtskirchinger
Copy link
Contributor

Yes.

You can see for yourself by switching out the header here https://godbolt.org/z/jodGv5vGM
with the header from #3446:
#include <https://raw.githubusercontent.com/falbrechtskirchinger/json/fix-c++20-issues-part2/single_include/nlohmann/json.hpp>

@nlohmann nlohmann linked a pull request Apr 25, 2022 that will close this issue
9 tasks
@nlohmann nlohmann added solution: proposed fix a fix for the issue has been proposed and waits for confirmation and removed state: help needed the issue needs help to proceed labels Apr 25, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue Apr 29, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue Apr 30, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue May 1, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue May 2, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue May 7, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue May 20, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue May 29, 2022
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this issue May 29, 2022
@nlohmann nlohmann added this to the Release 3.11.0 milestone May 29, 2022
@nlohmann nlohmann self-assigned this May 29, 2022
nlohmann pushed a commit that referenced this issue May 29, 2022
* Add C++20 3-way comparison operator and fix broken comparisons

Fixes #3207.
Fixes #3409.

* Fix iterators to meet (more) std::ranges requirements

Fixes #3130.
Related discussion: #3408

* Add note about CMake standard version selection to unit tests

Document how CMake chooses which C++ standard version to use when
building tests.

* Update documentation

* CI: add legacy discarded value comparison

* Fix internal linkage errors when building a module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants