Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 300b6d2

Browse files
committedDec 18, 2022
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
 

Diff for: ‎test/behavior/ptrcast.zig

+6
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)
Please sign in to comment.