You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2019/02/20 00:57:22 UTC

[impala] 02/04: IMPALA-5031: oversized signed shifts are undefined

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

tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 7bb5b03703538e88d83a413b9dc838e1eed7250a
Author: Jim Apple <jb...@apache.org>
AuthorDate: Sat Feb 16 20:55:56 2019 -0800

    IMPALA-5031: oversized signed shifts are undefined
    
    Standard section [expr.shift] says that E1 << E2 is undefined if E1 is
    of signed type and the result cannot be represented in the
    corresponding unsigned type. We can't simply change 1 << bit_width to
    1u << bit_width, though, becuase it is the second argument of the
    modulo operator, and following [expr.mul], "If the second operand of /
    or % is zero the behavior is undefined."
    
    This expression is tripped in RleTest.ValueSkippingFuzzy, with the
    following backtrace:
    
    util/rle-test.cc:304:29: runtime error: shift exponent 32 is too large
          for 32-bit type 'int'
        #0 RleTest::MakeRandomSequence(unsigned int, int, int, int)::
             {lambda(int)#1}::operator()(int) const util/rle-test.cc:304:29
        #1 RleTest::MakeRandomSequence(unsigned int, int, int, int)
             util/rle-test.cc:315:15
        #2 RleTest_ValueSkippingFuzzy_Test::TestBody()
             util/rle-test.cc:392:25
    
    Change-Id: I7debbd1ca5bd3ae640701ce0e95a12c5059abfd7
    Reviewed-on: http://gerrit.cloudera.org:8080/12514
    Reviewed-by: Tim Armstrong <ta...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/util/rle-test.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/be/src/util/rle-test.cc b/be/src/util/rle-test.cc
index 826c8da..1e3caec 100644
--- a/be/src/util/rle-test.cc
+++ b/be/src/util/rle-test.cc
@@ -301,6 +301,7 @@ class RleTest : public ::testing::Test {
       return uni_dist(random_eng) == 0;
     };
     auto NextVal = [bit_width](int val) {
+      if (bit_width == CHAR_BIT * sizeof(int)) return val + 1;
       return (val + 1) % (1 << bit_width);
     };