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

Aleksei Voitylov avoitylov at openjdk.java.net
Fri Apr 30 12:37:51 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.

This pull request has now been integrated.

Changeset: eb8db12c
Author:    Aleksei Voitylov <avoitylov at openjdk.org>
Committer: David Holmes <dholmes at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/eb8db12ce67b10957fa94fbf61d9a30db34ec01a
Stats:     2 lines in 1 file changed: 1 ins; 0 del; 1 mod

8263396: Atomic::CmpxchgByteUsingInt::set_byte_in_int needs an explicit cast

Reviewed-by: dholmes

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

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


More information about the hotspot-runtime-dev mailing list