RFR: 8346914: UB issue in scalbnA
Johan Sjölen
jsjolen at openjdk.org
Thu Jun 5 14:36:50 UTC 2025
On Thu, 5 Jun 2025 13:00:48 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> I like this change. It's easier to follow, at least for me.
>
> I think that is equivalent, but I did not want to disrupt the general control flow of the algorithm so that it still closely resembles the original fdlibm code.
>
> I also initially misread your suggestion and now I am wondering if I can actually simplify it to a simple two line change:
>
> unsigned u_k = k + n; // avoid UB signed integer overflow
> k = (int) u_k; // safely assign to k
>
> does that bypass any UB?
@dholmes-ora , if `k = (int) u_k;` does not say to the compiler that it can assume that `0 <= u_k < 2**31 - 1`, then this seems like a good changeset. Frankly, I would not trust myself in this matter, I find this very finicky.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25656#discussion_r2129013530
More information about the hotspot-dev
mailing list