RFR: 8313249: Fix -Wconversion warnings in verifier code [v2]
David Holmes
dholmes at openjdk.org
Sun Jul 30 11:55:52 UTC 2023
On Sat, 29 Jul 2023 19:19:49 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> I've struggled with the raw cast versus checked_cast usage in this PR - I could not determine what was guiding the usage of each type of cast. Shouldn't it always be a checked cast? Or does the preceding range check validate the use of a raw cast (so we don't range check twice)?
>
> To me, the two lines serves two purposes:
>
>
> assert(appends > 0 && appends < 4, "Invalid append amount");
>
> This is the input expected by this function.
>
>
> return static_cast<u1>(251 + appends);
>
>
> This is a mechanical check that the code is actually correctly written (i.e., you didn't mess up and wrote (253 + appends). That way the reader doesn't have do the math in order to trust this code.
True - the assert is checking a precondition; the checked_cast would be checking a postcondition.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1278556176
More information about the hotspot-runtime-dev
mailing list