Skip to content

Commit 300b6d2

Browse files
committed
add behavior test for comptime pointer casting
closes #1150 closes #1292 closes #4093
1 parent 6ed0910 commit 300b6d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/behavior/ptrcast.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ test "comptime ptrcast keeps larger alignment" {
203203
}
204204
}
205205

206+
test "comptime ptrcast" {
207+
const is_value = ~@intCast(isize, std.math.minInt(isize));
208+
const is_bytes = @ptrCast([*]const u8, &is_value)[0..@sizeOf(isize)];
209+
try expect(is_bytes[0] == 0xff);
210+
}
211+
206212
test "implicit optional pointer to optional anyopaque pointer" {
207213
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
208214
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO

0 commit comments

Comments
 (0)