JDK-8299688 : Adopt C++14 compatible std::bit_cast introduced in C++20
  • Type: Enhancement
  • Component: hotspot
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2023-01-05
  • Updated: 2023-01-09
Related Reports
Relates :  
Description
Hotspot currently has many places using C style casts, static_cast, or reinterpret_cast to convert between representations without changing the underlying bit representation.

C++20 introduced std::bit_cast for this purpose and it is well defined. It is actually possible to implement bit_cast for C++14, without some constexpr support.

This feature request is to refactor PrimitiveConversions::cast to bit_cast, expand bit_cast to support all compatible types, and use __builtin_bit_cast where available while falling back to the original implementations in PrimitiveConversions::cast. It then will replace some legacy conversion techniques with bit_cast.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11865 Date: 2023-01-05 18:04:29 +0000
05-01-2023