RFR: 8358957: [ubsan]: The assert in layout_helper_boolean_diffbit() in klass.hpp needs UB to fail [v4]
Afshin Zafari
azafari at openjdk.org
Thu Nov 6 12:09:11 UTC 2025
On Tue, 4 Nov 2025 23:47:40 GMT, Dean Long <dlong at openjdk.org> wrote:
>> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>>
>> comments and post-cond
>
> src/hotspot/share/oops/klass.hpp line 525:
>
>> 523: // So use alternate form of negation to avoid warning.
>> 524: uint result = candidates & (~candidates + 1);
>> 525: assert(((result - 1) & result) == 0, "post-condition");
>
> Maybe use "must be power of 2" instead of "post-condition". Also, this value is never going to change. Can we make the function `constexpr`?
Assert's message updated.
`constexpr` cannot be used unless all the called functions (alh and its descendents) are also `constexpr`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27288#discussion_r2498708371
More information about the hotspot-dev
mailing list