RFR: 8313249: Fix -Wconversion warnings in verifier code [v4]
Coleen Phillimore
coleenp at openjdk.org
Mon Jul 31 19:35:53 UTC 2023
On Mon, 31 Jul 2023 19:12:49 GMT, Dean Long <dlong at openjdk.org> wrote:
>> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add another static_cast
>
> src/hotspot/share/classfile/stackMapTableFormat.hpp line 552:
>
>> 550: static u1 appends_to_frame_type(int appends) {
>> 551: assert(appends > 0 && appends < 4, "Invalid append amount");
>> 552: return static_cast<u1>(251 + appends);
>
> The problem I have with assert + unchecked cast in general is that future maintainers might accidentally remove or break the assert check so we are left with an unchecked cast that truncates out-of-range values. For that reason I would like to see a checked_cast here. Even if we could do something like `RangeCheckedInt<1,3> appends` and get rid of the assert, I would probably keep the checked_cast because it catches human error.
Ok, I'll change both of them in this file.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1279778554
More information about the hotspot-runtime-dev
mailing list