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

Afshin Zafari azafari at openjdk.org
Mon Feb 9 21:27:41 UTC 2026


On Sun, 8 Feb 2026 18:49:57 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> src/hotspot/share/utilities/integerCast.hpp line 39:
>> 
>>> 37: // for the To Type.  From and To must be integral types.  This is used by
>>> 38: // integer_cast to test for tautological conversions.
>>> 39: template<typename From, typename To,
>> 
>> The order of From and To parameters is not consistent with the rest of the other templates.
>
> The parameter order here is consistent with the `std::is_convertible<>` and
> `std::is_base_of<>` traits. It "reads" similarly, i.e. it returns true if
> `From` is convertible to `To`. The order of the template parameters for the
> others is required in order to allow the `To` parameter to be explicit
> (necessary) while the `From` parameter is (always in actual usage) deduced.

OK. Thanks for the explanation. With the To then From order, the test cases would have been read consistently with other usages of the templates.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29582#discussion_r2781608911


More information about the hotspot-dev mailing list