mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-08 23:29:53 +01:00
dc51386b9f
This was originally motivated by `REQUIRE((a <=> b) == 0)` no longer compiling using MSVC. After some investigation, I found that they changed their implementation of the zero literal detector from the previous pointer-constructor with deleted other constructors, into one that uses `consteval` constructor from int. This breaks the previous detection logic, because now `is_foo_comparable<std::strong_ordering, int>` is true, but actually trying to compare them is a compile-time error... The solution was to make the decomposition `constexpr` and rely on a late C++20 DR that makes it so that `consteval` propagates up through the callstack of `constexpr` functions, until it either runs out of `constexpr` functions, or succeeds. However, the default handling of types in decomposition is to take a reference to them. This reference never becomes dangling, but because the constexpr evaluation engine cannot prove this, decomposition paths taking references to objects cannot be actually evaluated at compilation time. Thankfully we already did have a value-oriented decomposition path for arithmetic types (as these are common linkage-less types), so we could just explicitly spell out the `std::foo_ordering` types as also being supposed to be decomposed by-value. Two more fun facts about these changes 1) The original motivation of the MSVC change was to avoid trigering a `Wzero-as-null-pointer-constant` warning. I still do not believe this was a good decision. 2) Current latest version of MSVC does not actually implement the aforementioned C++20 DR, so even with this commit, MSVC cannot compile `REQUIRE((a <=> b) == 0)`. |
||
---|---|---|
.. | ||
Approx.tests.cpp | ||
BDD.tests.cpp | ||
Benchmark.tests.cpp | ||
Class.tests.cpp | ||
Compilation.tests.cpp | ||
Condition.tests.cpp | ||
Decomposition.tests.cpp | ||
EnumToString.tests.cpp | ||
Exception.tests.cpp | ||
Generators.tests.cpp | ||
Matchers.tests.cpp | ||
MatchersRanges.tests.cpp | ||
Message.tests.cpp | ||
Misc.tests.cpp | ||
Skip.tests.cpp | ||
ToStringByte.tests.cpp | ||
ToStringChrono.tests.cpp | ||
ToStringGeneral.tests.cpp | ||
ToStringOptional.tests.cpp | ||
ToStringPair.tests.cpp | ||
ToStringTuple.tests.cpp | ||
ToStringVariant.tests.cpp | ||
ToStringVector.tests.cpp | ||
ToStringWhich.tests.cpp | ||
Tricky.tests.cpp | ||
VariadicMacros.tests.cpp |