aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/slice.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-03-27 06:55:48 -0400
committerVeikka Tuominen <git@vexu.eu>2023-03-28 23:12:19 +0300
commitdd66e0addb30d795a04324096c913ca89ccbcf40 (patch)
tree928cf49e81d9047d629ff40832719d40dd3cca0f /test/behavior/slice.zig
parent2b805526033b0446fba7f38990df707204e7e23a (diff)
downloadzig-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.zig16
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" {