diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-01-11 16:09:17 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-13 22:13:44 -0700 |
| commit | b019a19b5546d51865175359ec1ae8e5aa3f4128 (patch) | |
| tree | 72bc02abdac799f9aa3eeee9714cc8c13fe4bc49 /test/behavior/array_llvm.zig | |
| parent | 75b6637d6013b735d36da0ab6e5655002a1b59e9 (diff) | |
| download | zig-b019a19b5546d51865175359ec1ae8e5aa3f4128.tar.gz zig-b019a19b5546d51865175359ec1ae8e5aa3f4128.zip | |
Sema: comptime loads and stores for `elem_ptr`
The index is checked against actual array lengths, and now handles
coerced or casted pointers to single items.
Diffstat (limited to 'test/behavior/array_llvm.zig')
| -rw-r--r-- | test/behavior/array_llvm.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/behavior/array_llvm.zig b/test/behavior/array_llvm.zig index 8e65045210..3fca269034 100644 --- a/test/behavior/array_llvm.zig +++ b/test/behavior/array_llvm.zig @@ -33,3 +33,15 @@ test "read/write through global variable array of struct fields initialized via }; try S.doTheTest(); } + +test "implicit cast single-item pointer" { + try testImplicitCastSingleItemPtr(); + comptime try testImplicitCastSingleItemPtr(); +} + +fn testImplicitCastSingleItemPtr() !void { + var byte: u8 = 100; + const slice = @as(*[1]u8, &byte)[0..]; + slice[0] += 1; + try expect(byte == 101); +} |
