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

Julian Waters jwaters at openjdk.org
Mon Jan 23 11:05:11 UTC 2023


On Mon, 23 Jan 2023 07:41:38 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> 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>
>
> src/hotspot/share/utilities/bitCast.hpp line 54:
> 
>> 52: constexpr To bit_cast(const From& from) {
>> 53: #if HAS_BUILTIN(__builtin_bit_cast) && !defined(__APPLE__)
>> 54:   return __builtin_bit_cast(To, from);
> 
> Throughout, I see no good reason to uglify the code with platform-specific conditional code
> when the portable version is just fine.  And then the supporting infrastructure to define that
> macro isn't needed.  The `!defined(__APPLE__)` makes this seem particularly problematic.
> Is the new `HAS_BUILTIN` just broken?  Or is `__builtin_bit_cast` broken for Macs?  Or what?

I also don't like the direct call to __builtins either, gcc to my knowledge automatically replaces the appropriate builtins when optimization is specified

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

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


More information about the hotspot-dev mailing list