RFR: JDK-8299688: Adopt C++14 compatible std::bit_cast introduced in C++20 [v4]

Justin King jcking at openjdk.org
Tue Jan 17 16:00:23 UTC 2023


On Fri, 13 Jan 2023 16:19:51 GMT, Justin King <jcking at openjdk.org> wrote:

>> Adopts a C++14 compatible implementation of [std::bit_cast](https://en.cppreference.com/w/cpp/numeric/bit_cast).
>> 
>> `PrimitiveConversions::cast` is refactored into `bit_cast` and extended to support all compatible types. Additionally it makes use of `__builtin_bit_cast` when available, which is strictly well defined compared to fallback approaches which are sometimes lurking in undefined behavior territory.
>> 
>> Lastly some legacy casting is updated to use `bit_cast` in `utilities/globalDefinitions.hpp`.
>
> Justin King has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove addressof as nobody should be overloading operator&
>   
>   Signed-off-by: Justin King <jcking at google.com>

@kimbarrett Friendly poke. Benefit is when we eventually get to C++20 we can just do `using std::bit_cast`.

-------------

PR: https://git.openjdk.org/jdk/pull/11865


More information about the hotspot-dev mailing list