RFR: 8358957: [ubsan]: The assert in layout_helper_boolean_diffbit() in klass.hpp needs UB to fail [v5]

Kim Barrett kbarrett at openjdk.org
Fri Nov 7 19:07:03 UTC 2025


On Fri, 7 Nov 2025 11:01:48 GMT, Afshin Zafari <azafari at openjdk.org> wrote:

>> src/hotspot/share/oops/klass.hpp line 524:
>> 
>>> 522:     // Use well known bit hack to isolate the low bit of candidates.
>>> 523:     // The usual form is (x & -x), but VS warns (C4146) about unary minus of unsigned.
>>> 524:     // So use alternate form of negation to avoid warning.
>> 
>> "So explicitly use two's complement to avoid warning"
>
> Done.

Alternatively, use `PRAGMA_DISABLE_MSVC_WARNING(4146)` to kill the warning.
I think there are a couple of places where we've done that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27288#discussion_r2505047897


More information about the hotspot-dev mailing list