diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-21 10:30:36 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-21 10:31:11 -0400 |
| commit | 44f2ee101f244342ec7e4cd81bb21d9a0c23267b (patch) | |
| tree | e3e1ea2c38df41bfb37fbeafe0cdc5fc02652437 /test | |
| parent | 073f7ebb0e2168d04212fd855235c3543f86a2be (diff) | |
| download | zig-44f2ee101f244342ec7e4cd81bb21d9a0c23267b.tar.gz zig-44f2ee101f244342ec7e4cd81bb21d9a0c23267b.zip | |
fix comptime slice of pointer to array
closes #1565
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/eval.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/cases/eval.zig b/test/cases/eval.zig index acb3da72c7..6e64a64aee 100644 --- a/test/cases/eval.zig +++ b/test/cases/eval.zig @@ -710,3 +710,16 @@ test "@bytesToslice on a packed struct" { var f = @bytesToSlice(F, b); assert(f[0].a == 9); } + +test "comptime pointer cast array and then slice" { + const array = []u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; + + const ptrA: [*]const u8 = @ptrCast([*]const u8, &array); + const sliceA: []const u8 = ptrA[0..2]; + + const ptrB: [*]const u8 = &array; + const sliceB: []const u8 = ptrB[0..2]; + + assert(sliceA[1] == 2); + assert(sliceB[1] == 2); +} |
