RFR: 8337683: Fix -Wconversion problem with arrayOop.hpp [v5]

Stefan Karlsson stefank at openjdk.org
Thu Aug 8 07:41:32 UTC 2024


On Thu, 8 Aug 2024 05:08:52 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   See if GHA compilers like this.
>
> src/hotspot/share/utilities/byteswap.hpp line 67:
> 
>> 65: struct ByteswapFallbackImpl<T, 2> {
>> 66:   inline constexpr uint16_t operator()(uint16_t x) const {
>> 67:     return checked_cast<uint16_t>(((x & UINT16_C(0x00ff)) << 8) | ((x & UINT16_C(0xff00)) >> 8));
> 
> What is the type of the expression without the cast?

The type of the expression is `int`.

https://en.cppreference.com/w/cpp/language/implicit_conversion

> In particular, [arithmetic operators](https://en.cppreference.com/w/cpp/language/operator_arithmetic) do not accept types smaller than int as arguments, and integral promotions are automatically applied after lvalue-to-rvalue conversion, if applicable.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20431#discussion_r1708844436


More information about the hotspot-dev mailing list