Commit 0b3a4ecf authored by Zequan Wu's avatar Zequan Wu Committed by Commit Bot

Fix implicit conversion loses integer precision warning

The type of m is long in 64 bits build, and results implicit conversion
loses integer precision, which was found by improved clang warning
(-Wshorten-64-to-32)

Bug: chromium:1124085
Change-Id: Ic9f22508bd817a06d5c90162b1ac3554a7171529
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2391323
Commit-Queue: Zequan Wu <zequanwu@google.com>
Auto-Submit: Zequan Wu <zequanwu@google.com>
Reviewed-by: 's avatarNico Weber <thakis@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69686}
parent c52b3bf2
......@@ -336,14 +336,14 @@ inline T RoundDown(T x, intptr_t m) {
STATIC_ASSERT(std::is_integral<T>::value);
// m must be a power of two.
DCHECK(m != 0 && ((m & (m - 1)) == 0));
return x & -m;
return x & static_cast<T>(-m);
}
template <intptr_t m, typename T>
constexpr inline T RoundDown(T x) {
STATIC_ASSERT(std::is_integral<T>::value);
// m must be a power of two.
STATIC_ASSERT(m != 0 && ((m & (m - 1)) == 0));
return x & -m;
return x & static_cast<T>(-m);
}
// Return the smallest multiple of m which is >= x.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment