RFR: 8318127: align_up has potential overflow [v2]

Kim Barrett kbarrett at openjdk.org
Tue Oct 1 14:22:43 UTC 2024


On Mon, 23 Sep 2024 11:19:47 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> 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.)
>
>> There's no "perhaps" about the intended meaning in the JBS issue. I wrote that issue; I remember what I meant. 
> 
> Sorry, I didn't mean to suggest otherwise. I was quibbling about the "mathematical result", but it's not important.
> 
>> :) 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.)
> 
> It seems we have a genuine difference of opinion about what the user can reasonably expect. I'd expect modular arithmetic, because C++ says so. However, I'll withdraw my objection, if only for the sake of not spending too much time discussing this issue.

BTW @theRealAph , regarding your example of the address of the the end of the page at the end of memory,
pointer arithmetic is not modular, and instead overflow is UB.

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

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


More information about the hotspot-dev mailing list