From 370b92a2ea95f45deb46dfbd6fb04a705bd37c76 Mon Sep 17 00:00:00 2001 From: xy720 <22125576+xy720@users.noreply.github.com> Date: Tue, 30 Aug 2022 17:58:54 +0800 Subject: [PATCH] [Bug](compile) fix clang build for be (#12183) --- be/src/util/bit_packing.inline.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/be/src/util/bit_packing.inline.h b/be/src/util/bit_packing.inline.h index 51efbb125d..f7222cfebe 100644 --- a/be/src/util/bit_packing.inline.h +++ b/be/src/util/bit_packing.inline.h @@ -35,6 +35,13 @@ inline int64_t BitPacking::NumValuesToUnpack(int bit_width, int64_t in_bytes, in } } +constexpr uint64_t GetMask(int num_bits) { + if (num_bits >= 64) { + return ~0L; + } + return (1ULL << num_bits) - 1; +} + template constexpr bool IsSupportedUnpackingType() { return std::is_same::value || std::is_same::value || @@ -176,7 +183,7 @@ inline uint64_t ALWAYS_INLINE UnpackValue(const uint8_t* __restrict__ in_buf) { static_assert(WORDS_TO_READ <= 3, "At most three 32-bit words need to be loaded."); constexpr int FIRST_BIT_OFFSET = FIRST_BIT_IDX - FIRST_WORD_IDX * 32; - constexpr uint64_t mask = BIT_WIDTH == 64 ? ~0L : (1UL << BIT_WIDTH) - 1; + constexpr uint64_t mask = GetMask(BIT_WIDTH); const uint32_t* const in = reinterpret_cast(in_buf); // Avoid reading past the end of the buffer. We can safely read 64 bits if we know that