From 37afab2addab5809e1419a09e3be5ea4f3ee5501 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Wed, 7 Sep 2022 19:21:12 +0300 Subject: Sema: preserve alignment of const decl pointers Closes #12769 --- test/behavior/pointers.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/behavior/pointers.zig') 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); +} -- cgit v1.2.3