RFR: 8324833: Signed integer overflows in ABS [v3]
Dean Long
dlong at openjdk.org
Mon Feb 5 23:50:32 UTC 2024
On Fri, 2 Feb 2024 09:47:28 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> See the details in the bug. I think current `ABS` implementation is beyond repair, and we should just switch to `uabs`.
>>
>> Additional testing:
>> - [x] Linux x86_64 fastdebug, `all` with `-ftrapv` (now fully passes!)
>> - [x] Linux x86_64 fastdebug, `all`
>
> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
>
> Touchups
The undefined behavior I was talking about is what abs(INT_MIN) returns on two's complement, and the problem with checked_cast is that checked_cast<int,uint>(0x80000000u) won't complain, because the bits match, but having the sign change to negative may not be what the caller wants, especially when using ABS.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17617#issuecomment-1928053407
More information about the graal-dev
mailing list