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

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


On Wed, 7 Aug 2024 21:05:05 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Since base_offset_in_bytes and HeapWordSize are int, there's no loss of conversion in making these variables int.  This seems trivial.
>> Tested with tier1 on linux and windows.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   See if GHA compilers like this.

Marked as reviewed by stefank (Reviewer).

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?

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

PR Review: https://git.openjdk.org/jdk/pull/20431#pullrequestreview-2227089884
PR Review Comment: https://git.openjdk.org/jdk/pull/20431#discussion_r1708848081


More information about the hotspot-dev mailing list