[libcxx-commits] [PATCH] D75960: [libc++] Implement C++20's P0476r2: std::bit_cast
Eric Fiselier via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 11 20:21:39 PDT 2020
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.
Herald added a reviewer: libc++.
LGTM other than the lack of tests.
We should also figure out what GCC's plan is here, so we can implement a GCC version in future.
================
Comment at: libcxx/include/bit:366
+_LIBCPP_INLINE_VISIBILITY
+constexpr _ToType bit_cast(_FromType const& __from) noexcept
+{
----------------
We should probably mark this nodiscard.
================
Comment at: libcxx/include/bit:371
+ static_assert(is_trivially_copyable_v<_FromType>);
+ return __builtin_bit_cast(_ToType, __from);
+}
----------------
Gosh. `__builtin_bit_cast` is a weird builtin -- taking a type as the first parameter.
================
Comment at: libcxx/include/bit:373
+}
+#endif
+
----------------
`#endif // !defined(_LIBCPP_HAS_NO_BUILTIN_BIT_CAST)`
================
Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.fail.cpp:58
+ // __builtin_bit_cast is an implementation detail of libc++.
+ // expected-error@* 0-3 {{__builtin_bit_cast}}
+
----------------
Are these errors emitted inside `<bit>`? If so, we should specify that here.
================
Comment at: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp:24
+ // TODO fun stuff
+ return true;
+}
----------------
What's the fun stuff?
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