Rust "unsafe" is not code the compiler doesn't understand
Rust "unsafe" is not code the compiler doesn't understand
Posted Dec 14, 2025 11:56 UTC (Sun) by sammythesnake (guest, #17693)In reply to: Rust "unsafe" is not code the compiler doesn't understand by khim
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
The *actual* problem is the way the border around the territory of nasal demons is defined.
It is possible to define languages where it is impossible to write a program with UB. C is not that language.
It is possible to design a programming language where the realm of UB is clearly delimited by simple rules that can easily be checked by a human of mortal intellect. C is not that language.
It is possible to design a programming language where the realm of UB is technically delimited by rules that can be checked before the heat death of the universe by a computer that could, in principle, be constructed. C is not that language.
It is possible, though of questionable utility/wisdom, to design language where the realm of UB is defined in terms of mathematically undecideble, fundamentally unsolvable problems (such as the Halting Problem}. THIS is the language C is.
Writing a non-trivial C program without UB *may* be possible, using MISRA style, intrinsics, compiler extensions etc. but doing so in standard C *and proving there is no UB* is not.
That's not my idea of an effective way to communicate with the computer...
IFF you can exclude UB, then there are large classes of provably equivalent constructions that can reliably underlie optimisations. With UB, *all* transformations are "correct", including "return 0;" -> "emit_olfactory_fiends();"
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
