RFR: 8263446: Avoid unary minus over unsigned type in ObjectSynchronizer::dec_in_use_list_ceiling

Daniel D.Daugherty dcubed at openjdk.java.net
Thu Mar 11 15:36:07 UTC 2021


On Thu, 11 Mar 2021 13:26:33 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Surely SonarCloud is simply wrong about this. Unary minus on unsigned is well-defined in C and C++.
>
>> Surely SonarCloud is simply wrong about this. Unary minus on unsigned is well-defined in C and C++.
> 
> Yes, it yields another unsigned value. I'd prefer `Atomic::sub` to do this for us, and check stuff along the way. More on that Sonar rule: https://rules.sonarsource.com/c/RSPEC-876

I also think that SonarCloud is wrong about this.

@fisk had good reasons to prefer Atomic::add() of a negative value over
using Atomic::sub() back when we were working on this ObjectMonitor code.
Hopefully, he can chime in on this thread.

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

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


More information about the hotspot-runtime-dev mailing list