RFR: 8312121: Fix -Wconversion warnings in tribool.hpp

Dean Long dlong at openjdk.org
Mon Jul 17 18:49:06 UTC 2023


On Mon, 17 Jul 2023 02:59:08 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/share/utilities/tribool.hpp line 44:
>> 
>>> 42:   TriBool() : _value(0) {}
>>> 43:   TriBool(bool value) : _value(value) {
>>> 44:     _value = _value | 2;
>> 
>> You can also do like line 39 and use `(u1)(expr) & 3` or `((expr & 3u)` also seems to work.
>
> Or cast the `2` to `(u1)2` ?

It does seem strange that this code is using a bit-field, but still using & | and shift.  Why not represent the high and low bit with two separate bit-fields of width 1?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14892#discussion_r1265769859


More information about the hotspot-dev mailing list