test_allowzero.zig (297B) - Raw
1 const std = @import("std"); 2 const expect = std.testing.expect; 3 4 test "allowzero" { 5 var zero: usize = 0; // var to make to runtime-known 6 _ = &zero; // suppress 'var is never mutated' error 7 const ptr: *allowzero i32 = @ptrFromInt(zero); 8 try expect(@intFromPtr(ptr) == 0); 9 } 10 11 // test