4 ms·
> it's trivial to construct a non nullable pointer that is null or uninitialised This is checked at runtime in ReleaseSafe. jamie@machine:~$ cat test.zig
by jamii 6y ago
> it's trivial to construct a non nullable pointer that is null or uninitialised
This is checked at runtime in ReleaseSafe.
jamie@machine:~$ cat test.zig
pub fn main() void {
var x: usize = 3;
_ = @intToPtr(*u32, x - 3).*;
}
jamie@machine:~$ zig run test.zig -OReleaseSafe
cast causes pointer to be null
Aborted (core dumped)
(The x-3 is because if you use a literal 0 it gets caught at compile time)