4 ms·
This is definitely true right now, but I don't think it will always be the case. Unsafe Rust is currently extremely underspecified and underdocumented, but it'
by NobodyNada 2y ago
This is definitely true right now, but I don't think it will always be the case.
Unsafe Rust is currently extremely underspecified and underdocumented, but it's designed to be far more specifiable than C. For example: aliasing rules. When and how you're allowed to alias references in unsafe code is not at all documented and under much active discussion; whereas in C pointer aliasing rules are well defined but also completely insane (casting pointers to a different type in order to reinterpret the bytes of an object is often UB even in completely innocuous cases).
Once Rust's memory model is fully specified and written down, unsafe Rust is trying to go for something much simpler, more teachable, and with less footguns than C.
Huge props to Ralf Jung and the opsem team who are working on answering these questions & creating a formal specification: https://github.com/rust-lang/unsafe-code-guidelines/issues https://github.com/rust-lang/unsafe-code-guidelines/issues