aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorr00ster91 <r00ster91@proton.me>2023-05-28 01:04:26 +0200
committerr00ster91 <r00ster91@proton.me>2023-06-27 19:08:24 -0400
commit11c32c756f70540250139d6825937da53d74740a (patch)
tree81a2688fcbcc989384677192faccc264d5f07818 /src
parent5804f3f75716ee77382880954cf73cd4005f33f7 (diff)
downloadzig-11c32c756f70540250139d6825937da53d74740a.tar.gz
zig-11c32c756f70540250139d6825937da53d74740a.zip
fix u65529 and above overflowing in more places
See also #15537
Diffstat (limited to 'src')
-rw-r--r--src/value.zig4
1 files changed, 2 insertions, 2 deletions
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