3 ms·
> As you might imagine, this operation is HIGHLY DANGEROUS.There’s nothing to stop you from transmuting 0 into a borrow, &T and then trying to dereference it. V
by ch 12y ago
> As you might imagine, this operation is HIGHLY DANGEROUS.There’s nothing to stop you from transmuting 0 into a borrow, &T and then trying to dereference it. Voila, null pointer dereferencing in Rust!
Is this right? Why doesn't this function need to be marked unsafe?
- fjh 12y agotransmute is marked as unsafe, so it can only be used in unsafe blocks or functions.
- ch 12y agoMy mistake. I clicked through to the docs, and didn't see any annotation. http://static.rust-lang.org/doc/master/std/mem/fn.transmute.html http://static.rust-lang.org/doc/master/std/mem/fn.transmute....
- chrismorgan 12y agoErk—that’s a bug.
- ossreality 12y agoThat's because it's doc'd here: http://static.rust-lang.org/doc/master/core/intrinsics/ffi.transmute.html http://static.rust-lang.org/doc/master/core/intrinsics/ffi.t...