RFR: 8314258: checked_cast doesn't properly check some cases [v2]

Kim Barrett kbarrett at openjdk.org
Fri Feb 13 20:06:52 UTC 2026


On Mon, 9 Feb 2026 21:27:18 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Please review this addition of the `integer_cast` utility.
>> 
>> Details in first comment, to avoid email spamming from automatic messages.
>> 
>> Testing: mach5 tier1-5 with `checked_cast` for integral types changed to call
>> the new `integer_cast`.  Addition of `integer_cast` includes gtests.
>
> Kim Barrett has updated the pull request incrementally with one additional commit since the last revision:
> 
>   more testing

float -> integer conversions are another place where the round-trip test used
by `checked_cast` is not correct. If the value of the float exceeds the
maximum value of the integer type, the conversion is UB.

Similarly for integer -> float conversions, but unless we're dealing with
greater than 64bit integer types or floating point types significantly more
restricted than IEEE single float, exceeding the range isn't possible.

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

PR Comment: https://git.openjdk.org/jdk/pull/29582#issuecomment-3899177895


More information about the hotspot-dev mailing list