Sema: preserve alignment of const decl pointers

Closes #12769
This commit is contained in:
Veikka Tuominen
2022-09-07 19:21:12 +03:00
parent 0fa80e66b7
commit 37afab2add
2 changed files with 12 additions and 0 deletions

View File

@@ -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);
}