Commit 540130650f

Veikka Tuominen <git@vexu.eu>
2022-09-19 16:06:57
Sema: pass calculated offset to `elemPtrType` in `elemPtrSlice`
1 parent 541b3e3
Changed files (2)
src
test
behavior
src/Sema.zig
@@ -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()) {
test/behavior/align.zig
@@ -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);
+}