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

Coleen Phillimore coleenp at openjdk.org
Thu Aug 8 11:18:33 UTC 2024


On Thu, 8 Aug 2024 07:38:33 GMT, Stefan Karlsson <stefank 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/runtime/atomic.hpp line 1122:
> 
>> 1120:   volatile uint32_t* aligned_dest
>> 1121:     = reinterpret_cast<volatile uint32_t*>(align_down(dest, sizeof(uint32_t)));
>> 1122:   uint32_t offset = checked_cast<uint32_t>(pointer_delta(dest, aligned_dest, 1));
> 
> If this works for all compilers, then that's great. I was a bit concerned that the code in the statement below would cause a warning:
> 
> (sizeof(uint32_t) - 1 - offset)
> 
> 
> given that `sizeof` returns a `size_t` and `1` an `int`, but I guess the compilers are smart enough to figure out that they all fit within a uint32_t?

gcc doesn't complain about this with -Wsign-conversion, or at least as included with arrayOop.hpp, which was the only goal of this change was to fix the new -Wconversion warning with arrayOop.hpp.

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

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


More information about the hotspot-dev mailing list