RFR: 8314258: checked_cast doesn't properly check some cases
Kim Barrett
kbarrett at openjdk.org
Tue Feb 10 05:54:32 UTC 2026
On Mon, 9 Feb 2026 09:47:13 GMT, Afshin Zafari <azafari at openjdk.org> wrote:
> Using explicit cast as in the lines at the bottom of the test makes the conversion possible. How the `(int32_t)0xFFFFFFFF` compiled/converted?
Recall that the type of 0xFFFFFFFF is an unsigned integral type.
Because that _value_ can't be represented in an int32_t, casting it to such
results in an implementation-defined value (C++17 7.8/3). All supported
platforms define that to produce -1 of type int32_t (two's complement), as
does C++20. And -1 is in the int32_t destination's range.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29582#issuecomment-3875482559
More information about the hotspot-dev
mailing list