Skip to content

Commit

Permalink
Resolve ambiguity in simd_word test by explicitly casting size_t to u…
Browse files Browse the repository at this point in the history
…int64_t for << operator usage

author: @sengthai (https://github.com/sengthai)
  • Loading branch information
Strilanc committed Apr 27, 2024
1 parent 8c83d9b commit 65b1ab0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/stim/mem/simd_word.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ TEST_EACH_WORD_SIZE_W(simd_word, shifting, {
for (size_t k = 0; k < W; k++) {
std::array<uint64_t, W / 64> expected{};
expected[k / 64] = uint64_t{1} << (k % 64);
EXPECT_EQ((w << k).to_u64_array(), expected) << k;
EXPECT_EQ((w << static_cast<uint64_t>(k)).to_u64_array(), expected) << k;
if (k > 0) {
EXPECT_EQ(((w << (k - 1)) << 1).to_u64_array(), expected) << k;
EXPECT_EQ(((w << (static_cast<uint64_t>(k) - 1)) << 1).to_u64_array(), expected) << k;
}
EXPECT_EQ(w, (w << k) >> k) << k;
EXPECT_EQ(w, (w << static_cast<uint64_t>(k)) >> static_cast<uint64_t>(k)) << k;
}

ASSERT_EQ(w << 0, 1);
Expand All @@ -127,8 +127,8 @@ TEST_EACH_WORD_SIZE_W(simd_word, shifting, {
ASSERT_EQ(w >> 2, 0);
ASSERT_EQ((w << 5) >> 5, 1);
ASSERT_EQ((w >> 5) << 5, 0);
ASSERT_EQ((w << (W - 1)) << 1, 0);
ASSERT_EQ((w << (W - 1)) >> (W - 1), 1);
ASSERT_EQ((w << static_cast<uint64_t>(W - 1)) << 1, 0);
ASSERT_EQ((w << static_cast<uint64_t>(W - 1)) >> static_cast<uint64_t>(W - 1), 1);
})

TEST_EACH_WORD_SIZE_W(simd_word, masking, {
Expand Down

0 comments on commit 65b1ab0

Please sign in to comment.