From ae417711f623d08e3f0d67d636182cbf66c31ebd Mon Sep 17 00:00:00 2001 From: jpboth Date: Sat, 31 Mar 2018 11:16:43 +0200 Subject: [PATCH] Update valuevec.rs I ran into an overflow with bits_per_val = 32 --- src/valuevec.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/valuevec.rs b/src/valuevec.rs index 7a19b9d..b64232d 100644 --- a/src/valuevec.rs +++ b/src/valuevec.rs @@ -34,7 +34,8 @@ impl ValueVec { let bits = bits_per_val*count; ValueVec { bits_per_val: bits_per_val, - mask: 2u32.pow(bits_per_val as u32)-1, + // to avoid overflow in case bits_per_val equals 32 + mask: if bits_per_val < 32 {2u32.pow(bits_per_val as u32)-1} else { 0xFFFFFFFF} , bits: BitVec::from_elem(bits,false), } }