RFR: JDK-8263396: Atomic::CmpxchgByteUsingInt::set_byte_in_int needs an explicit cast
Aleksei Voitylov
avoitylov at openjdk.java.net
Tue Apr 27 18:22:45 UTC 2021
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.
-------------
Commit messages:
- add static cast
Changes: https://git.openjdk.java.net/jdk/pull/3723/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3723&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8263396
Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/3723.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/3723/head:pull/3723
PR: https://git.openjdk.java.net/jdk/pull/3723
More information about the hotspot-runtime-dev
mailing list