[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
Wed Jan 13 21:37:04 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() {
ldionne wrote:
> zoecarver wrote:
> > I assume this means you're against using `__builtin_bit_cast ` to test `std::bit_cast`? Fair enough. 
> Yes, because `std::bit_cast` is implemented as a single call to `__builtin_bit_cast`. I feel like what we're actually testing here is in fact `__builtin_bit_cast` directly, not just `std::bit_cast`.
Fair enough. Ideally, Clang's tests would be sufficient, but I see where you're coming from. I think that makes sense. 

Would it make it better if the call to `__builtin_bit_cast` always casted it to a `char` array and compared the bytes? That would basically be re-implementing memcmp. If we can verify that the cast to `char` array always works, then we can use that to test other things, maybe. 

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list