3 ms·
Both Rust and C/C++ have some important limitations when it comes to being categorically UB-free. Rust's limitations first: - If there's `unsafe` code in your
by oconnor663 4y ago
Both Rust and C/C++ have some important limitations when it comes to being categorically UB-free. Rust's limitations first:
- If there's `unsafe` code in your dependencies, that's potentially just as bad as `unsafe` code in your own project. So you do have to be careful with what you pull in.
- There are known "soundness holes" in the compiler, i.e. compiler bugs that let you corrupt memory without writing `unsafe`. However, the ones that remain are pretty obscure and very hard to hit accidentally.
Now C and C++'s limitations:
- Valgrind and all the sanitizers depend on test coverage. So 100% line coverage is table stakes for getting certainty out of these. And you probably also need to think about coverage of your dependencies.
- None of these tools catch the UB that results from violating the "strict aliasing" rules. I believe there's something called "TypeSan" that promises to improve this situation, but it's experimental?