Fixed signed integer overflow

(1 << num_bits)  was converted to a signed integer that caused an overflow (as num_bits was usually set to 31). It worked fine since the value was later converted back to uint32_t but signed integer overflow is technically an undefined behavior and it was triggering errors in our automated tests.
This commit is contained in:
Ondrej Stava
2020-06-11 12:18:59 -07:00
committed by GitHub
parent 00edf6396c
commit 52147e5a99

View File

@@ -3814,7 +3814,7 @@ namespace basist
assert(num_bits < 32);
assert(val < (1ULL << num_bits));
uint32_t mask = (1 << num_bits) - 1;
uint32_t mask = (1ULL << num_bits) - 1;
while (num_bits)
{