aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/pointers.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-01-22 00:36:50 -0500
committerGitHub <noreply@github.com>2023-01-22 00:36:50 -0500
commita51c76541d60da81ef53e0ab1f221a80d9956bd5 (patch)
tree023a1f1fbc02b646214b70d78dad0acb7ec158f3 /test/behavior/pointers.zig
parentf85c01d4c7520d2242626f4c0684ab97e47af373 (diff)
parentaa626deadddcf26a5789d29d5ba88c978ee53b89 (diff)
downloadzig-a51c76541d60da81ef53e0ab1f221a80d9956bd5.tar.gz
zig-a51c76541d60da81ef53e0ab1f221a80d9956bd5.zip
Merge pull request #14403 from Vexu/fixes
Misc fixes
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);
+}