Re:Rustproofing Linux (Part 1/4 Leaking Addresses) (2023)
by zesterer on Wednesday August 28, 2024 @08:48AM
(#41378887)
That's... simply not true. Pointer arithmetic is not, in general, safe. Example: https://doc.rust-lang.org/std/primitive.pointer.html#method....
Re:Rustproofing Linux (Part 1/4 Leaking Addresses) (2023)
by gpm on Sunday September 01, 2024 @11:08AM
(#41417581)
Eh... the ptr::add function exists if you want to make extra promises to the compiler to let it optimize better, but if you don't a safe version exists: https://doc.rust-lang.org/std/primitive.pointer.html#method....
The often surprising part of raw pointers to system programmers newly dabbling in Rust is that every operation on them is safe, except for deref. You can freely take addresses and do pointer arithmetic on them without having to deal with unsafe, and only have to tell the compiler that you know what you are doing when you either load or store something through them.