diff options
| author | Timon Kruiper <timonkruiper@gmail.com> | 2020-04-01 20:40:13 +0200 |
|---|---|---|
| committer | Timon Kruiper <timonkruiper@gmail.com> | 2020-04-01 20:50:09 +0200 |
| commit | ae6965a4e73cd5aad04e1c6831f48e7f0ecafc04 (patch) | |
| tree | d18ea56cc85ff06642fa5d4b63cc263200488981 /src/bigint.cpp | |
| parent | d9cf779b47573f750f9e6ffb6373bfcb75b1632e (diff) | |
| download | zig-ae6965a4e73cd5aad04e1c6831f48e7f0ecafc04.tar.gz zig-ae6965a4e73cd5aad04e1c6831f48e7f0ecafc04.zip | |
Fix undefined behavior when shift amount is 64
Diffstat (limited to 'src/bigint.cpp')
| -rw-r--r-- | src/bigint.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp index 644e25837e..dd04363e82 100644 --- a/src/bigint.cpp +++ b/src/bigint.cpp @@ -1430,7 +1430,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) { uint64_t digit = op1_digits[op_digit_index]; size_t dest_digit_index = op_digit_index - digit_shift_count; digits[dest_digit_index] = carry | (digit >> leftover_shift_count); - carry = digit << (64 - leftover_shift_count); + carry = (leftover_shift_count != 0) ? (digit << (64 - leftover_shift_count)) : 0; if (dest_digit_index == 0) { break; } op_digit_index -= 1; |
