Rust "unsafe" is not code the compiler doesn't understand
Rust "unsafe" is not code the compiler doesn't understand
Posted Nov 17, 2025 16:04 UTC (Mon) by khim (subscriber, #9252)In reply to: Rust "unsafe" is not code the compiler doesn't understand by farnz
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
> [1] As an example of a non-trivial property, "does this program read from free memory, or only allocated memory" is non-trivial.
That's important “non-trivial property”, sure, but it's not the most devastating one. The critical “non-trivial property”, that also can not be tested is “does that programs always behave identically to naïvely generated code with zero optimizations or not” is also undecidable.
This, essentially, blows up the whole “undefined behavior is reading error” idea to spliters: we may argue about whether undefined behavior is reading error or not till we are blue in face, but the simple fact remains: it's mathematically impossible to write a C compiler that wouldn't “miscompile” some programs with undefined behaviors… the only question is which programs it may miscompile and which ones it should compile correctly… but that's question of changing the undefined behaviors list, not question of changes to the underfined behavior definition.
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.
