3 ms·
Zig has a nullable pointer type, which will have null checks. But only in ReleaseSafe build mode, and it's trivial to construct a non nullable pointer that is n
by the_duke 6y ago
Zig has a nullable pointer type, which will have null checks. But only in ReleaseSafe build mode, and it's trivial to construct a non nullable pointer that is null or uninitialised.
So I agree with your disagreement.
- quietbritishjim 6y agoI'm not familiar with Zig, and I'm afraid I didn't quite follow your comment. Are you saying that "runtime" should instead be "none" for Zig?
- masklinn 6y agoDepends on the exact guarantees e.g. technically it's trivial to construct a nullable reference in Rust, but it's also `unsafe` and flagrantly UB so...
- 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)