| 1 | const expectEqual = @import("std").testing.expectEqual; |
| 2 | |
| 3 | test "comptime @ptrFromInt" { |
| 4 | comptime { |
| 5 | // Zig is able to do this at compile-time, as long as |
| 6 | // ptr is never dereferenced. |
| 7 | const ptr: *i32 = @ptrFromInt(0xdeadbee0); |
| 8 | const addr = @intFromPtr(ptr); |
| 9 | try expectEqual(usize, @TypeOf(addr)); |
| 10 | try expectEqual(0xdeadbee0, addr); |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | // test |