3 ms·
> If you have two mutable references to the same thing at the end of an unsafe block, you'll won't get an issue in the unsafe code This is wrong AFAIK: having
by cesarb 7y ago
> If you have two mutable references to the same thing at the end of an unsafe block, you'll won't get an issue in the unsafe code
This is wrong AFAIK: having two mutable references to the same thing is undefined behavior even within an unsafe block. An unsafe block only allows extra functionality (like dereferencing raw pointers), it doesn't change the semantics of functionality that's already allowed outside an unsafe block. That is: what would be undefined behavior outside an unsafe block is still undefined behavior inside an unsafe block.