From 80a0f2a118b858b3ceb4ae0ae09d72353d58c928 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 12 Jul 2020 16:45:49 +0200 Subject: common/alignment: Fix compilation errors (#4303) --- src/common/alignment.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/alignment.h b/src/common/alignment.h index f8c49e079..b37044bb6 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -11,7 +11,9 @@ namespace Common { template constexpr T AlignUp(T value, std::size_t size) { static_assert(std::is_unsigned_v, "T must be an unsigned value."); - return static_cast(value + (size - value % size) % size); + auto mod{static_cast(value % size)}; + value -= mod; + return static_cast(mod == T{0} ? value : value + size); } template -- cgit v1.2.3