Daniel Becker has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/19792


Change subject: IMPALA-12086: Fix BitUtil::CountLeadingZeros for zero
......................................................................

IMPALA-12086: Fix BitUtil::CountLeadingZeros for zero

BitUtil::CountLeadingZeros() uses _builtin_clz() and _builtin_clzll() to
return the number of leading zeros in a number. Calling these functions
with 0 is undefined.

This change introduces a check in CountLeadingZeros() to only call these
functions if the argument is non-zero.

Also makes CountLeadingZeros() constexpr and restricts it to type sizes
that can actually be handled by the function.

Testing:
 - Added a test for CountLeadingZeros() in bit-util-test.cc

Change-Id: I0ae3d84c5c25871388155747f91c51162c1a0590
---
M be/src/util/arithmetic-util.h
M be/src/util/bit-util-test.cc
M be/src/util/bit-util.h
3 files changed, 53 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/92/19792/1
--
To view, visit http://gerrit.cloudera.org:8080/19792
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ae3d84c5c25871388155747f91c51162c1a0590
Gerrit-Change-Number: 19792
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Becker <[email protected]>

Reply via email to