Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ rotl(T value, int rotate) {
return value;
if (rotate < 0)
return cpp::rotr<T>(value, -rotate);
return (value << rotate) | (value >> (N - rotate));
return static_cast<T>((value << rotate) | (value >> (N - rotate)));
}

template <typename T>
Expand All @@ -244,7 +244,7 @@ rotr(T value, int rotate) {
return value;
if (rotate < 0)
return cpp::rotl<T>(value, -rotate);
return (value >> rotate) | (value << (N - rotate));
return static_cast<T>((value >> rotate) | (value << (N - rotate)));
}

// TODO: Do we need this function at all? How is it different from
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/__support/CPP/bit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ TYPED_TEST(LlvmLibcBitTest, HasSingleBit, UnsignedTypes) {
constexpr auto LSB = T(1);
constexpr auto MSB = T(~(ALL_ONES >> 1));
for (T value = 1; value; value <<= 1) {
auto two_bits_value = value | ((value <= MIDPOINT) ? MSB : LSB);
T two_bits_value =
static_cast<T>(value | ((value <= MIDPOINT) ? MSB : LSB));
EXPECT_FALSE(has_single_bit<T>(two_bits_value));
}
}
Expand Down