aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/pointers.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-09-07 19:21:12 +0300
committerVeikka Tuominen <git@vexu.eu>2022-09-08 00:37:11 +0300
commit37afab2addab5809e1419a09e3be5ea4f3ee5501 (patch)
tree44a909a2351c3f3434325c5b38f545d8b7960abd /test/behavior/pointers.zig
parent0fa80e66b7e995e560ac1c3da7069c603e9a0538 (diff)
downloadzig-37afab2addab5809e1419a09e3be5ea4f3ee5501.tar.gz
zig-37afab2addab5809e1419a09e3be5ea4f3ee5501.zip
Sema: preserve alignment of const decl pointers
Closes #12769
Diffstat (limited to 'test/behavior/pointers.zig')
-rw-r--r--test/behavior/pointers.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig
index adbc308742..dcdea1ff80 100644
--- a/test/behavior/pointers.zig
+++ b/test/behavior/pointers.zig
@@ -486,3 +486,14 @@ test "array slicing to slice" {
try S.doTheTest();
comptime try S.doTheTest();
}
+
+test "pointer to constant decl preserves alignment" {
+ const S = struct {
+ a: u8,
+ b: u8,
+ const aligned align(8) = @This(){ .a = 3, .b = 4 };
+ };
+
+ const alignment = @typeInfo(@TypeOf(&S.aligned)).Pointer.alignment;
+ try std.testing.expect(alignment == 8);
+}