Merge pull request #6904 from tf2spi/6889-count-bits

Resolve panic on 64-bit overflow
This commit is contained in:
gingerBill
2026-06-29 10:30:00 +01:00
committed by GitHub
2 changed files with 3 additions and 2 deletions

View File

@@ -296,8 +296,7 @@ gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success
gb_internal bool big_int_can_be_represented_in_64_bits(BigInt const *x) {
int bits_used = (x->used-1) * MP_DIGIT_BIT;
return bits_used <= 64;
return mp_count_bits(x) <= 64;
}
gb_internal u64 big_int_to_u64(BigInt const *x) {

View File

@@ -3421,6 +3421,8 @@ gb_internal void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *nod
x->expr = node;
x->value = exact_value_shift(be->op.kind, exact_value_to_integer(x->value), exact_value_to_integer(y->value));
check_is_expressible(c, x, x->type);
return;
}