RFR: 8318127: align_up has potential overflow [v4]

Casper Norrbin cnorrbin at openjdk.org
Wed Oct 9 14:19:38 UTC 2024


On Wed, 9 Oct 2024 13:43:00 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Casper Norrbin has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - update copyright header
>>  - align_up death tests
>
> test/hotspot/gtest/utilities/test_align.cpp line 164:
> 
>> 162: static void test_fail_alignment() {
>> 163:   A alignment = max_alignment<A>();
>> 164:   T value = std::numeric_limits<T>::max() - checked_cast<T>(alignment) + 10;
> 
> I think a simpler expression here would be
> 
> T value = align_down(std::numeric_limits<T>::max(), alignment) + 1;
> 
> I found it a bit harder to convince myself the original was correct.

Changed now! I agree that this is clearer.

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

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


More information about the hotspot-dev mailing list