Rust vs. C
Rust vs. C
Posted Oct 18, 2024 6:13 UTC (Fri) by mb (subscriber, #50428)In reply to: Rust vs. C by blackfire
Parent article: Smart pointers for the kernel
Hm, are you sure that just having two aliasing nonconst raw pointers is insta-UB?
That doesn't look right to me.
Posted Oct 18, 2024 7:56 UTC (Fri)
by blackfire (guest, #92738)
[Link]
Having multiple raw pointers (const or not) is fine, having multiple mut references (or one mut and 1+ const) is UB, even without dereferencing any of them.
(this is made mildly more complex by stacked borrows but that's the gist and honestly I don't claim to fully understand the intricacies of the model, but you do have to watch out for UB any time you make a reference from a raw pointer)
Rust vs. C
> That doesn't look right to me.