RFR: 8314258: checked_cast doesn't properly check some cases
Dean Long
dlong at openjdk.org
Mon Oct 16 23:21:27 UTC 2023
On Mon, 16 Oct 2023 02:03:26 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> src/hotspot/share/gc/g1/g1CodeRootSet.cpp line 192:
>>
>>> 190: // we would grow again quickly.
>>> 191: const float WantedLoadFactor = 0.5;
>>> 192: assert((current_size / WantedLoadFactor) <= SIZE_MAX, "table overflow");
>>
>> Surprisingly, this might not work. See https://bugs.openjdk.org/browse/JDK-8287052.
>
> It looks like for clang we should use -Wimplicit-int-conversion instead of
> gcc's "-Wconversion -fno-float-conversion". clang seems to have a much richer
> set of warning controls in this area than does gcc.
>
> It looks like for clang we should use -Wimplicit-int-conversion instead of
> gcc's "-Wconversion -fno-float-conversion". clang seems to have a much richer
> set of warning controls in this area than does gcc.
>
> That way we don't implicitly get -Wimplicit-int-float-conversion, which is
> what is triggering the warning mentioned in JDK-8287052. In this case the
> loss of precision leading to that warning does not seem important.
In my experiments, values up to 0x4000000000000200 will get pass the assert, but then we should hit a different assert later in round_up_power_of_2(). SIZE_MAX can't be represented exactly as a double, so it gets rounded up, and then that assert doesn't correctly check for overflow.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16005#discussion_r1361351061
More information about the hotspot-dev
mailing list