authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-05 20:45:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-06 02:54:58-05:00
log36da3000c0076c5a2bd0b2258718510cf11dd3e2
tree959a6b70ab1ebb7171d7dd527183d5c959cda91f
parent80be5e483278a38e5f8f55fced55ebb38c3978a1

Sema: resolve elem type for non-default aligned ptrs

Before this commit, I observe a crash from this abiSize call because the element type is a struct that is not yet resolved. This is triggered by running the behavior tests with -ofmt=c -target x86_64-windows.

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

src/Sema.zig+1-1
...@@ -32535,7 +32535,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {...@@ -32535,7 +32535,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {
32535 }32535 }
32536 // If the addend is not a comptime-known value we can still count on32536 // If the addend is not a comptime-known value we can still count on
32537 // it being a multiple of the type size.32537 // it being a multiple of the type size.
32538 const elem_size = elem_ty.abiSize(target);32538 const elem_size = try sema.typeAbiSize(elem_ty);
32539 const addend = if (offset) |off| elem_size * off else elem_size;32539 const addend = if (offset) |off| elem_size * off else elem_size;
3254032540
32541 // The resulting pointer is aligned to the lcd between the offset (an32541 // The resulting pointer is aligned to the lcd between the offset (an