MISRA C is not provably safe.
MISRA C is not provably safe.
Posted Nov 19, 2025 14:22 UTC (Wed) by tialaramex (subscriber, #21167)In reply to: MISRA C might be provably safe. by gmatht
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
MISRA-C;2012 R17.5 describes an ambition C cannot fulfil. It might almost as well say "Programs shall not have bugs". For rule 17.5 it wants to specify that the array size is part of the parameter type, but in C that is nonsense, the array types always decay to pointers here. You can write this out in C but C compilers will ignore your intent.
You can actually do what MISRA-C calls for here in Rust, and I have, exactly once, because it's very rarely actually useful. The case where I did took memory pages, they're always exactly 4096 bytes long (no, I don't handle huge pages), and I specified that the function takes only (references to) arrays of precisely 4096 bytes, so for Rust passing some other size won't compile for the same reason you can't pass a boolean to a function which takes a string - they're different types. C doesn't provide any such thing and MISRA can't imagine it into existence.
Obeying MISRA's style is a sign of compliance, which is a useful trait for safety systems, but to a considerable extent it's functioning as a Brown M&M check, it's not a proof of anything.
