From 11c32c756f70540250139d6825937da53d74740a Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Sun, 28 May 2023 01:04:26 +0200 Subject: fix u65529 and above overflowing in more places See also #15537 --- src/value.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/value.zig') diff --git a/src/value.zig b/src/value.zig index 6b85ebd552..af2bf209cc 100644 --- a/src/value.zig +++ b/src/value.zig @@ -616,7 +616,7 @@ pub const Value = struct { .Int, .Enum => { const int_info = ty.intInfo(mod); const bits = int_info.bits; - const byte_count = (bits + 7) / 8; + const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8); var bigint_buffer: BigIntSpace = undefined; const bigint = val.toBigInt(&bigint_buffer, mod); @@ -859,7 +859,7 @@ pub const Value = struct { }; const int_info = int_ty.intInfo(mod); const bits = int_info.bits; - const byte_count = (bits + 7) / 8; + const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8); if (bits == 0 or buffer.len == 0) return mod.getCoerced(try mod.intValue(int_ty, 0), ty); if (bits <= 64) switch (int_info.signedness) { // Fast path for integers <= u64 -- cgit v1.2.3