Skip to content

Commit

Permalink
Fix MSVC warning in MathCommon
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271835

Reviewed by Yusuke Suzuki.

In `toIntImpl` a warning, C4334, is emitted because MSVC is implicitly
converting the result of a 32-bit shift to 64-bit. By making an explicit
cast the warning is silenced.

* Source/JavaScriptCore/runtime/MathCommon.h:

Canonical link: https://commits.webkit.org/276799@main
  • Loading branch information
donny-dont committed Mar 28, 2024
1 parent f91aeb9 commit 33e3497
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/runtime/MathCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ ALWAYS_INLINE Int toIntImpl(double number)
// As a result, the exp of the double is always >= 31. We can take advantage
// of this by specifically checking for (exp == 31) and give the compiler a
// chance to constant fold the operations below.
const constexpr UInt missingOne = 1U << intBitsMinusOne;
const constexpr UInt missingOne = static_cast<UInt>(1U) << intBitsMinusOne;
result &= missingOne - 1;
result += missingOne;
}
} else {
if (exp < static_cast<int32_t>(intBits)) {
const UInt missingOne = 1U << exp;
const UInt missingOne = static_cast<UInt>(1U) << exp;
result &= missingOne - 1;
result += missingOne;
}
Expand Down

0 comments on commit 33e3497

Please sign in to comment.