authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-22 19:58:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-23 00:56:52-08:00
logaef1da1634ae12d90e9d59fc0184dadaea38830c
tree6e388667a7888daa04651afb6b7e6bd98068d52b
parentc0e0bb385cec80f3c370fb9e1c3b7116fae1bd9c

Sema: use Sema.typeAbiSize rather than Type.abiSize

This resolves the type instead of asserting that the type is resolved, fixing a crash.

1 files changed, 2 insertions(+), 2 deletions(-)

src/Sema.zig+2-2
......@@ -16575,7 +16575,7 @@ fn analyzePtrArithmetic(
1657516575 }
1657616576 // If the addend is not a comptime-known value we can still count on
1657716577 // it being a multiple of the type size.
16578 const elem_size = Type.fromInterned(ptr_info.child).abiSize(mod);
16578 const elem_size = try sema.typeAbiSize(Type.fromInterned(ptr_info.child));
1657916579 const addend = if (opt_off_val) |off_val| a: {
1658016580 const off_int = try sema.usizeCast(block, offset_src, try off_val.toUnsignedIntAdvanced(sema));
1658116581 break :a elem_size * off_int;
......@@ -16612,7 +16612,7 @@ fn analyzePtrArithmetic(
1661216612 const offset_int = try sema.usizeCast(block, offset_src, try offset_val.toUnsignedIntAdvanced(sema));
1661316613 if (offset_int == 0) return ptr;
1661416614 if (try ptr_val.getUnsignedIntAdvanced(mod, sema)) |addr| {
16615 const elem_size = Type.fromInterned(ptr_info.child).abiSize(mod);
16615 const elem_size = try sema.typeAbiSize(Type.fromInterned(ptr_info.child));
1661616616 const new_addr = switch (air_tag) {
1661716617 .ptr_add => addr + elem_size * offset_int,
1661816618 .ptr_sub => addr - elem_size * offset_int,