[libcxx-commits] [PATCH] D75960: [libc++] Implement C++20's P0476r2: std::bit_cast
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 12 15:19:08 PST 2021
zoecarver added inline comments.
================
Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp:208
+// TODO: There doesn't seem to be a way to perform non-trivial correctness
+// tests inside constexpr.
+constexpr bool basic_constexpr_test() {
----------------
I assume this means you're against using `__builtin_bit_cast ` to test `std::bit_cast`? Fair enough.
================
Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp:43
+ }
+ assert(__builtin_memcmp(&value1, &value2, sizeof(T)) == 0);
+}
----------------
ldionne wrote:
> zoecarver wrote:
> > So, in non-constexpr, the only thing you're testing here is that you can cast a pointer to its current type?
> I don't understand. In `constexpr` mode, the only thing being tested is that the roundtrip from `T` back to `T` (through `std::bit_cast`) works as expected. I'm only unable to test the intermediate results (the `char` arrays).
>
> However, as of rebasing this patch, it appears that none of it works anymore. So I don't have a way to test `bit_cast` inside `constexpr`.
This comment was referring to [[ https://reviews.llvm.org/D75960?id=250245 | the old patch ]] where there was an `is_constant_evaluated` condition in the `test_buffer_roundtrip` function.
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