[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
Tue Jan 12 14:40:12 PST 2021

ldionne added inline comments.

Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.fail.cpp:31
+int main(int, char**)
+    // Not the same size
zoecarver wrote:
> Maybe a deleted copy constructor? 
I think that's covered by the test for a type that isn't trivially copyable. If a type is not copyable, then it is not trivially copyable.

Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp:43
+    }
+    assert(__builtin_memcmp(&value1, &value2, sizeof(T)) == 0);
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`.

Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp:194
+        3.141592653589793238462643383279502884197169399375105820974944,
+        std::nanl("")
+    };
jfb wrote:
> Some of these won't work on all platforms. You'll need to selectively disable some for platforms that don't have IEEE-754 with the expected sizes.
I'll see what CI complains about!

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list