aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/pointers.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behavior/pointers.zig')
-rw-r--r--test/behavior/pointers.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig
index c8879453ad..d93e991889 100644
--- a/test/behavior/pointers.zig
+++ b/test/behavior/pointers.zig
@@ -532,3 +532,18 @@ test "pointer alignment and element type include call expression" {
};
try expect(@alignOf(S.P) > 0);
}
+
+test "pointer to array has explicit alignment" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+
+ const S = struct {
+ const Base = extern struct { a: u8 };
+ const Base2 = extern struct { a: u8 };
+ fn func(ptr: *[4]Base) *align(1) [4]Base2 {
+ return @alignCast(1, @ptrCast(*[4]Base2, ptr));
+ }
+ };
+ var bases = [_]S.Base{.{ .a = 2 }} ** 4;
+ const casted = S.func(&bases);
+ try expect(casted[0].a == 2);
+}