This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/branch-1.18.x by this push:
     new 3891618ab [util] eliminate compiler warnings in RLE encoding debug 
checks
3891618ab is described below

commit 3891618abbcad1b61e41310637713fdc9382ecff
Author: kedeng <kdeng...@gmail.com>
AuthorDate: Fri Jun 20 12:39:50 2025 +0800

    [util] eliminate compiler warnings in RLE encoding debug checks
    
    This patch resolves two categories of compiler warnings in RLE encoding
    that were discovered during Rocky Linux compilation and also exist in 
CentOS:
    
    1. Boolean comparison warnings (-Wbool-compare):
       For T=bool and BIT_WIDTH=1, the debug check "value < (1LL << BIT_WIDTH)"
       (which evaluates to "value < 2") is always true for boolean values (0 or 
1),
       triggering warnings like:
    `
    /data/code/kudu/src/kudu/util/rle-encoding.h:388:37:
    warning: comparison of constant '2' with boolean expression is always true
    [-Wbool-compare]
    DCHECK(value < (1LL << BIT_WIDTH));
    ~~~~~^~~~~~~~~~~~~~~~~~~~
    `
    2. Shift overflow warnings (-Wshift-count-overflow):
    For BIT_WIDTH=64, the expression (1LL << 64) causes undefined behavior
    by shifting beyond long long's bit width, triggering warnings like:
    `
    /data/code/kudu/src/kudu/util/rle-encoding.h:388:44:
    warning: left shift count >= width of type [-Wshift-count-overflow]
    DCHECK(value < (1LL << BIT_WIDTH));
    ~~~~^~~~~~~~~~~~~
    `
    
    Change-Id: I230fb92acb18aeda29766f2f131beac9eca8dab9
    Reviewed-on: http://gerrit.cloudera.org:8080/23055
    Tested-by: Alexey Serbin <ale...@apache.org>
    Reviewed-by: Alexey Serbin <ale...@apache.org>
    (cherry picked from commit 1550f239ea6e50bb8f84a51255fe1b8accb536aa)
    Reviewed-on: http://gerrit.cloudera.org:8080/23059
    Tested-by: KeDeng <kdeng...@gmail.com>
    Reviewed-by: KeDeng <kdeng...@gmail.com>
---
 src/kudu/util/rle-encoding.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/kudu/util/rle-encoding.h b/src/kudu/util/rle-encoding.h
index dc50484a0..b9ffd2657 100644
--- a/src/kudu/util/rle-encoding.h
+++ b/src/kudu/util/rle-encoding.h
@@ -17,6 +17,8 @@
 
 #pragma once
 
+#include <type_traits>
+
 #include <glog/logging.h>
 
 #include "kudu/gutil/port.h"
@@ -382,7 +384,9 @@ inline size_t RleDecoder<T, BIT_WIDTH>::Skip(size_t 
to_skip) {
 // it decides whether they should be encoded as a literal or repeated run.
 template<typename T, uint8_t BIT_WIDTH>
 inline void RleEncoder<T, BIT_WIDTH>::Put(T value, size_t run_length) {
-  DCHECK(BIT_WIDTH == 64 || value < (1LL << BIT_WIDTH));
+  if constexpr (BIT_WIDTH < 64 && BIT_WIDTH > 1) {
+    DCHECK(value < (1LL << BIT_WIDTH));
+  }
 
   // TODO(perf): remove the loop and use the repeat_count_
   for (; run_length > 0; run_length--) {

Reply via email to