RFR: JDK-8263396: Atomic::CmpxchgByteUsingInt::set_byte_in_int needs an explicit cast

Aleksei Voitylov avoitylov at openjdk.java.net
Fri Apr 30 10:58:52 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.

Thank you David for the review. I agree with your assessment, just wanted to make sure not to spend time on this the next scanner shows this up. I assume the fix to be trivial.

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

PR: https://git.openjdk.java.net/jdk/pull/3723


More information about the hotspot-runtime-dev mailing list