RFR: 8318127: align_up has potential overflow

Kim Barrett kbarrett at openjdk.org
Sun Sep 22 11:05:41 UTC 2024


On Sun, 22 Sep 2024 08:43:03 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> The JBS issue is using "overflow" in the sense of "high bits of the mathematical result are discarded".
>> Fixed-width unsigned arithmetic can certainly overflow in that sense.
>
> Perhaps, although "overflow" has a precise definition in C++, but I would be extremely surprised if I were looking for the address of the end of the page at 0fffff_ffff and was informed of an overflow. IMO, _there is no overflow_ in that case, and the correct answer must be 0.

There's no "perhaps" about the intended meaning in the JBS issue. I wrote that
issue; I remember what I meant. :) I suppose I could have been more precise.

So I disagree. I think align_up has an implied post-condition that the result
is not less than the value being aligned. That's certainly how it's used, in
every occurrance I've looked at. (I admit I didn't look at all ~450 uses
though.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20808#discussion_r1770523394


More information about the hotspot-dev mailing list