[libcxx-commits] [PATCH] D75960: [libc++] Implement C++20's P0476r2: std::bit_cast
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 9 06:15:48 PDT 2021
ldionne added inline comments.
================
Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp:253
+int main(int, char**) {
+ tests();
+ static_assert(basic_constexpr_test());
----------------
jfb wrote:
> Quuxplusone wrote:
> > I guess I meant to try to constexpr-ify `tests()` but never succeeded. The problems were (I think) with `std::nanl` and `std::memcmp`. I think it would be fine to ship this with only the `basic_constexpr_test`; although you might also try putting the `memcmp`s under `if (!std::is_constant_evaluated())` and splitting out the floating-point `nan` tests into a non-constexpr special test.
> `nan` will be `constexpr` if you do `bool my_is_nan(double value) { return value != value; }`.
As Arthur says, the issue here is really to get a NaN value in constexpr context, which I don't know how to do. The other issue, which is more fundamental, is that we can't use `std::memcmp` in a constexpr context. And we can't use `__builtin_memcmp`, because although it *is* constexpr, it can't be used to compare different types, and we can't `reinterpret_cast` in a constexpr context.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75960/new/
https://reviews.llvm.org/D75960
More information about the libcxx-commits
mailing list