felipecrv commented on code in PR #41690:
URL: https://github.com/apache/arrow/pull/41690#discussion_r1607439474


##########
cpp/src/arrow/util/bit_util.h:
##########
@@ -282,15 +282,19 @@ static inline int Log2(uint64_t x) {
 
 // Bitmask selecting the k-th bit in a byte
 // static constexpr uint8_t kBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128};
-static constexpr uint8_t GetBitMask(uint8_t index) {
+template <typename T>
+static constexpr uint8_t GetBitMask(T index) {
   // DCHECK(index >= 0 && index <= 7);
+  ARROW_COMPILER_ASSUME(index >= 0 && index <= 7);
   return static_cast<uint8_t>(1) << index;
 }
 
 // the bitwise complement version of kBitmask
 // static constexpr uint8_t kFlippedBitmask[] = {254, 253, 251, 247, 239, 223, 
191, 127};
-static constexpr uint8_t GetFlippedBitMask(uint8_t index) {
+template <typename T>
+static constexpr uint8_t GetFlippedBitMask(T index) {
   // DCHECK(index >= 0 && index <= 7);
+  ARROW_COMPILER_ASSUME(index >= 0 && index <= 7);

Review Comment:
   `ARROW_COMPILER_ASSUME(index >= 0 && index <= 7)` is superfluous because 
shifts are already UB in C when the size is bigger than the bit-width of the 
integer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to