diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-03-27 06:55:48 -0400 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-03-28 23:12:19 +0300 |
| commit | dd66e0addb30d795a04324096c913ca89ccbcf40 (patch) | |
| tree | 928cf49e81d9047d629ff40832719d40dd3cca0f /test/behavior/slice.zig | |
| parent | 2b805526033b0446fba7f38990df707204e7e23a (diff) | |
| download | zig-dd66e0addb30d795a04324096c913ca89ccbcf40.tar.gz zig-dd66e0addb30d795a04324096c913ca89ccbcf40.zip | |
Sema: fix empty slice pointer value
We just checked that inst_child_ty was effectively a zero-bit type, so
it is certainly not the non-zero alignment we are looking for.
Closes #15085
Diffstat (limited to 'test/behavior/slice.zig')
| -rw-r--r-- | test/behavior/slice.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index 029f6838d0..a9aa9e50e1 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -723,10 +723,18 @@ test "slice with dereferenced value" { test "empty slice ptr is non null" { if (builtin.zig_backend == .stage2_aarch64 and builtin.os.tag == .macos) return error.SkipZigTest; // TODO - const empty_slice: []u8 = &[_]u8{}; - const p: [*]u8 = empty_slice.ptr + 0; - const t = @ptrCast([*]i8, p); - try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); + { + const empty_slice: []u8 = &[_]u8{}; + const p: [*]u8 = empty_slice.ptr + 0; + const t = @ptrCast([*]i8, p); + try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); + } + { + const empty_slice: []u8 = &.{}; + const p: [*]u8 = empty_slice.ptr + 0; + const t = @ptrCast([*]i8, p); + try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); + } } test "slice decays to many pointer" { |
