diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-01-22 00:36:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-22 00:36:50 -0500 |
| commit | a51c76541d60da81ef53e0ab1f221a80d9956bd5 (patch) | |
| tree | 023a1f1fbc02b646214b70d78dad0acb7ec158f3 /test/behavior/pointers.zig | |
| parent | f85c01d4c7520d2242626f4c0684ab97e47af373 (diff) | |
| parent | aa626deadddcf26a5789d29d5ba88c978ee53b89 (diff) | |
| download | zig-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.zig | 15 |
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); +} |
