Rust and UB
Rust and UB
Posted Aug 14, 2024 21:31 UTC (Wed) by khim (subscriber, #9252)In reply to: Rust and UB by josh
Parent article: Standards for use of unsafe Rust in the kernel
> The Rust compiler doesn't want to be an adversary.
That's an oversimplification. Rust complier doesn't have any wants or desires.
And any optimizing compiler is an adversary. And the better compiler is at optimizing code that conforms to the rules the more destructive it becomes when it had to deal with something that doesn't conform to these rules. It's just in the nature of the beast.
I think better characterization would be: rust compiler is mighty beast that can do lots of good, but failure to control it turns it into raging destructive force that may destroy everything — that's why it's responsibility of both compiler developers and language users to do their part of work that would keep that mighty and powerful yet crazy beast tamed.
We couldn't make “benign compiler” that lots of “we code for the hardware” folks dream about. But we could keep compiler's destructive tendencies in check if we would act together.
