RFR: 8313249: Fix -Wconversion warnings in verifier code [v4]
Dean Long
dlong at openjdk.org
Mon Jul 31 19:15:56 UTC 2023
On Mon, 31 Jul 2023 15:19:16 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> See bugid for comments. Most of the verifier code deals with ints, so the u2 and other parameters weren't really needed and can be promoted to int. Mostly types are changed, but a few checked_cast<>s are added.
>> Tested with tier1-4, sanity Oracle platforms.
>
> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1279760480
More information about the hotspot-runtime-dev
mailing list