diff --git a/src/common/memory_allocator.h b/src/common/memory_allocator.h index 5760b0c7..2d708235 100644 --- a/src/common/memory_allocator.h +++ b/src/common/memory_allocator.h @@ -76,7 +76,8 @@ class PageAllocator { template static T AlignUp(T offset, size_t alignment) { assert(alignment > 0 && ((alignment - 1) & alignment) == 0); - return (offset + (alignment - 1)) & ~(alignment - 1); + const T mask = static_cast(alignment - 1); + return (offset + mask) & ~mask; } // Allocates an array with requested amount of `bytes` and at a location with