Skip to content

Commit 0b3a4ec

Browse files
ZequanWuCommit Bot
authored andcommitted
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: Nico Weber <thakis@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/master@{#69686}
1 parent c52b3bf commit 0b3a4ec

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/base/macros.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,14 @@ inline T RoundDown(T x, intptr_t m) {
336336
STATIC_ASSERT(std::is_integral<T>::value);
337337
// m must be a power of two.
338338
DCHECK(m != 0 && ((m & (m - 1)) == 0));
339-
return x & -m;
339+
return x & static_cast<T>(-m);
340340
}
341341
template <intptr_t m, typename T>
342342
constexpr inline T RoundDown(T x) {
343343
STATIC_ASSERT(std::is_integral<T>::value);
344344
// m must be a power of two.
345345
STATIC_ASSERT(m != 0 && ((m & (m - 1)) == 0));
346-
return x & -m;
346+
return x & static_cast<T>(-m);
347347
}
348348

349349
// Return the smallest multiple of m which is >= x.

0 commit comments

Comments
 (0)