I saw a few places that were punning through a union of FP and integer, and that made me sad. Luckily, C++20 adds bit_cast for exactly that purpose. Implement our own version in ADT (without constexpr, leaving us a bit sad), and use it in the few places my grep-fu found silly union punning.
Details
Details
- Reviewers
javed.absar steven_wu srhines - Commits
- rGc4986cef12cd: ADT: add <bit> header, implement C++20 bit_cast, use
rG28655081a476: ADT: add <bit> header, implement C++20 bit_cast, use
rL341741: ADT: add <bit> header, implement C++20 bit_cast, use
rL341728: ADT: add <bit> header, implement C++20 bit_cast, use
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
Union punning is one of my pet peeves, so I am glad to see this. bit_cast seems generally useful too, so thanks for adding it.
Comment Actions
Reverted by r341730. Looks like missing std::is_trivially_copyable, and a missing include in the ARM change (which is what I get for not building that target by default...).
@rsmith points out the workaround in llvm/Support/type_traits.h