catch2/tests/SelfTest
Martin Hořeňovský dc51386b9f
Support literal-zero detectors using consteval int constructors
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)`.
2024-02-12 00:52:53 +01:00
..
Baselines Add uniform_integer_distribution 2023-12-10 19:53:39 +01:00
IntrospectiveTests Disable tests for reproducible FP on non-SSE2 x86 targets 2024-02-11 00:25:24 +01:00
Misc Move tests from projects/ to tests/ 2019-12-05 16:00:20 +01:00
TimingTests Fix references to license file 2022-10-28 11:30:15 +02:00
UsageTests Support literal-zero detectors using consteval int constructors 2024-02-12 00:52:53 +01:00
helpers Support literal-zero detectors using consteval int constructors 2024-02-12 00:52:53 +01:00
TestRegistrations.cpp Fix references to license file 2022-10-28 11:30:15 +02:00