diff options
| author | Robin Voetter <robin@voetter.nl> | 2021-10-24 20:37:09 +0200 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2021-10-25 20:41:15 +0200 |
| commit | 7062c8a8865bbd2fb8181b579da552295cd68e6a (patch) | |
| tree | afa5a38081c75c63599a1642a78266b347b1b5fd /test/behavior | |
| parent | 0942bf73c90eabf87d0ca965b50beb0fd9a8fc8c (diff) | |
| download | zig-7062c8a8865bbd2fb8181b579da552295cd68e6a.tar.gz zig-7062c8a8865bbd2fb8181b579da552295cd68e6a.zip | |
stage2: comptime slice of pointer to hardcoded address
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/slice_stage2.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/behavior/slice_stage2.zig b/test/behavior/slice_stage2.zig new file mode 100644 index 0000000000..360527e8ba --- /dev/null +++ b/test/behavior/slice_stage2.zig @@ -0,0 +1,12 @@ +const std = @import("std"); +const expect = std.testing.expect; + +const x = @intToPtr([*]i32, 0x1000)[0..0x500]; +const y = x[0x100..]; +test "compile time slice of pointer to hard coded address" { + try expect(@ptrToInt(x) == 0x1000); + try expect(x.len == 0x500); + + try expect(@ptrToInt(y) == 0x1400); + try expect(y.len == 0x400); +} |
