Re:C and C++ Prioritize Performance over Correctness
by celeritascelery on Friday August 18, 2023 @08:21PM
(#37184017)
Why couldn’t the Rust compiler also assume that dissimilar types don’t alias?
[ Parent
| on HN ]
Re:C and C++ Prioritize Performance over Correctness
by LegionMammal978 on Saturday August 19, 2023 @01:10PM
(#37190859)
Because existing unsafe code written in stable Rust depends on the ability to convert raw pointers and references from one type to another, as long as their memory layouts match. That's the whole premise of the bytemuck crate [0], and it's the basis for things like the &str-to-&[u8] or &[u8]-to-&str conversions in the standard library.