RFR: 8318127: align_up has potential overflow [v3]

Kim Barrett kbarrett at openjdk.org
Wed Oct 2 10:20:36 UTC 2024


On Wed, 2 Oct 2024 09:12:30 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. 
>> 
>> 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.
> 
> I wasn't talking about pointer arithmetic, as was explicit in my reply. I was talking about unsigned integer types.

That wasn't obvious to me, because of "the address of the end of the page at".  I took that to mean pointers were involved.

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

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


More information about the hotspot-dev mailing list