News for hackers. Stuff that matters.
Re:Comparative unsafety by pornel on Friday April 09, 2021 @09:12PM (#26758053)
Rust's actually-safe pointer arithmetic is done via slices (because it's necessary to track the length):

    slice = &slice[1..];
It compiles to roughly `ptr++; len--;` and a bounds check if necessary.

`1234 as *const u8` and `ptr.offset(n)` are also safe, because Rust allows invalid/dangling pointers to exist if they're never dereferenced.

Re:Comparative unsafety by rectang on Friday April 09, 2021 @09:55PM (#26758278)
This answer addresses the letter of jdc's musing, but not the gist. The code that you've supplied may be "safe", but the issue is that there's no way to constrain pointer arithmetic such that the result always points at a valid location which can withstand dereferencing.