Skip to content

Commit

Permalink
[c++] Cast after modulo operation to avoid overflow. Issue #579.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Nov 14, 2018
1 parent 750f915 commit 0af9e1c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ inline static int indexByTermCount(std::int64_t termCount) AERON_NOEXCEPT

inline static int indexByPosition(std::int64_t position, std::int32_t positionBitsToShift) AERON_NOEXCEPT
{
return (int)((std::uint64_t)position >> positionBitsToShift) % PARTITION_COUNT;
return static_cast<int>(((std::uint64_t)position >> positionBitsToShift) % PARTITION_COUNT);
}

inline static std::int64_t computePosition(
Expand Down

0 comments on commit 0af9e1c

Please # to comment.