diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-09-07 19:21:12 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-09-08 00:37:11 +0300 |
| commit | 37afab2addab5809e1419a09e3be5ea4f3ee5501 (patch) | |
| tree | 44a909a2351c3f3434325c5b38f545d8b7960abd /test | |
| parent | 0fa80e66b7e995e560ac1c3da7069c603e9a0538 (diff) | |
| download | zig-37afab2addab5809e1419a09e3be5ea4f3ee5501.tar.gz zig-37afab2addab5809e1419a09e3be5ea4f3ee5501.zip | |
Sema: preserve alignment of const decl pointers
Closes #12769
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/pointers.zig | 11 |
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); +} |
