by duneroadrunner · 10y ago · 0 comments
For those times when you have to use C++, SaferCPlusPlus[1] should help.
[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus
If the answer is code review, it will never work.
But in other circumstances, another valuable feature would be to be able to make your co-workers' (and predecessors') existing code retroactively safer. The easiest way to do that is probably by enabling the llvm/gcc sanitizers when compiling. But unfortunately that is often not a practical solution for several reasons[1], not least of which is the performance penalty.
So the more practical solution may be to use SaferCPlusPlus to replace (in a straight-forward but not quite automated manner) all the potentially dangerous C/C++ data types (pointers, arrays, etc.) with safe, fast compatible direct substitutes. Thereby salvaging existing code bases.
Wrt preventing the use of C/C++'s unsafe data types in new code, currently SaferCPlusPlus does not provide any mechanism for such enforcement. But you could imagine the effort required to implement such an enforcement mechanism might be small compared to rewriting some large code bases in, say, Rust. And in the mean time, even existing C++ static analyzers seem to be getting better at flagging potentially unsafe code.
[1] http://duneroadrunner.github.io/SaferCPlusPlus/#safercpluspl...
The majority of C++ programmers I meet at enterprise projects don't even know what is CppCon.