blob: dfcea537b530b6df4fc578c83dbc5f2a5048dbc6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
const std = @import("std");
const testing = std.testing;
const builtin = @import("builtin");
const a = [_]u8{ 1, 2, 3 };
fn checkAddress(s: []const u8) !void {
for (s) |*i, j| {
try testing.expect(i == &a[j]);
}
}
test "slices pointing at the same address as global array." {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
try checkAddress(&a);
comptime try checkAddress(&a);
}
|