Memory-safe C code
Memory-safe C code
Posted Nov 16, 2025 13:28 UTC (Sun) by tialaramex (subscriber, #21167)In reply to: Memory-safe C code by alx.manpages
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
I *think* if you're restricted to only the unsigned integer types and only a few arithmetic operators (not including division) you can make a "safe C" but I could be wrong, and anyway it's too restricted to be of any practical use.
In particular I'm pretty sure a "safe C" cannot have pointers at all. Safe Rust is allowed to make pointers, because it isn't allowed to dereference them and in Rust all the pointers are allowed to exist, even if they're nonsense, so long as we do not dereference them - in contrast my understanding is that in C nonsense pointers are prohibited because historically they might be impossible at runtime on some hardware.
