Sema: pass calculated offset to elemPtrType in elemPtrSlice

This commit is contained in:
Veikka Tuominen 2022-09-19 17:06:57 +03:00
parent 541b3e3a31
commit 540130650f
2 changed files with 6 additions and 1 deletions

View File

@ -22692,7 +22692,7 @@ fn elemPtrSlice(
break :o index;
} else null;
const elem_ptr_ty = try sema.elemPtrType(slice_ty, null);
const elem_ptr_ty = try sema.elemPtrType(slice_ty, offset);
if (maybe_undef_slice_val) |slice_val| {
if (slice_val.isUndef()) {

View File

@ -564,3 +564,8 @@ test "@alignCast null" {
const aligned: ?*anyopaque = @alignCast(@alignOf(?*anyopaque), ptr);
try expect(aligned == null);
}
test "alignment of slice element" {
const a: []align(1024) const u8 = undefined;
try expect(@TypeOf(&a[0]) == *align(1024) const u8);
}