RFR: JDK-8263396: Atomic::CmpxchgByteUsingInt::set_byte_in_int needs an explicit cast
David Holmes
dholmes at openjdk.java.net
Tue Apr 27 21:23:06 UTC 2021
On Tue, 27 Apr 2021 18:15:40 GMT, Aleksei Voitylov <avoitylov at openjdk.org> wrote:
> Hi,
>
> please review this PR to fix a problem found by SonarCloud. I think it's best to fix it to avoid confusion.
>
> As required by the standard, operands of arithmetical operators are implicitly promoted to at least int. Code being fixed assumes int to be at least 32 bits and all implicit promotions are performed to at least 32 bits. It's not a problem with any of the platforms supported by OpenJDK but it won't work correctly on platforms and compilers with 16 bit ints: shift operators will use 16 bit integer and anything shifted to bits 16:31 will be lost.
>
> Testing: original case with gcc bug on Arm 32 is not reproduced, pre-submit tests were run.
Hi Aleksei,
This seems harmless. But I very much doubt hotspot would build correctly on any system with only 16-bit ints (jint would have to be redefined to a 32-bit type, and then all the types used with jint would need similar adaptation.)
Cheers,
David
-------------
Marked as reviewed by dholmes (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/3723
More information about the hotspot-runtime-dev
mailing list