mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
15 lines
383 B
Zig
15 lines
383 B
Zig
const expect = @import("std").testing.expect;
|
|
|
|
test "comptime @ptrFromInt" {
|
|
comptime {
|
|
// Zig is able to do this at compile-time, as long as
|
|
// ptr is never dereferenced.
|
|
const ptr: *i32 = @ptrFromInt(0xdeadbee0);
|
|
const addr = @intFromPtr(ptr);
|
|
try expect(@TypeOf(addr) == usize);
|
|
try expect(addr == 0xdeadbee0);
|
|
}
|
|
}
|
|
|
|
// test
|