From 2e1b02a0e2cba7ce4acb615a3dd77c085ed7a712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 16 Feb 2024 21:54:25 +0100 Subject: [PATCH] Document issue with spaceship operator in assertion and MSVC --- docs/limitations.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/limitations.md b/docs/limitations.md index 099dd82a..f5f60ba8 100644 --- a/docs/limitations.md +++ b/docs/limitations.md @@ -173,3 +173,19 @@ TEST_CASE("b") { If you are seeing a problem like this, i.e. weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library. + +### Visual Studio 2022 -- can't compile assertion with the spaceship operator + +[The C++ standard requires that `std::foo_ordering` is only comparable with +a literal 0](https://eel.is/c++draft/cmp#categories.pre-3). There are +multiple strategies a stdlib implementation can take to achieve this, and +MSVC's STL has changed the strategy they use between two releases of VS 2022. + +With the new strategy, `REQUIRE((a <=> b) == 0)` no longer compiles under +MSVC. Note that Catch2 can compile code using MSVC STL's new strategy, +but only when compiled with a C++20 conforming compiler. MSVC is currently +not conformant enough, but `clang-cl` will compile the assertion above +using MSVC STL without problem. + +This change got in with MSVC v19.37](https://godbolt.org/z/KG9obzdvE). +