Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not for all the things that Rust catches. And not for the most important things.

Static analyzers typically catch trivial stuff like returning a pointer to a stack from a function. Which is easy to spot during code reviews. But they don't catch more sophisticated UB that can result from bad interaction of code in different units. And this it the kind of UB we're the most interested in being protected from.



If you mean lifetimes, yes you can, with the latest Visual Studio 2019, although it is WIP.

And compiling in debug does enable bounds checking for arrays, vectors and iterators invalidation.

Rust still needs to define what actually is UB in unsafe blocks, how multiple implementations might affect the language and a memory model.

Not saying that it is perfect, rather that it can be made safer than how many make use of it, which is important, because there are plenty of codebases out there that will never get rewritten into something else.


In C++ lifetimes are not encoded in types. Therefore I seriously doubt it can do the lifetime analysis with such accuracy as Rust can, particularly if the whole source code (e.g. libraries) is not available.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: