Summary
We have seen in this chapter how it’s too easy to write unsafe code by default in C++. Despite the improvements introduced by subsequent standards, by the STL collections and smart pointers, it’s still likely that programmers will make mistakes with a potentially huge cost. Sure, there are ways to catch these mistakes: automated developer tests, exploratory tests, penetration testing, and so on. But the defaults of the language matter, and C++’s defaults are still unsafe.
After examining these issues, my only option is to conclude that C++ is still memory-unsafe by default and that writing memory-safe code requires continuous attention and the appropriate tools. The safety profiles that will hopefully arrive soon in the standard will most likely alleviate many of the issues, but there’s still an unfathomable quantity of C++ code in the world that was written like it’s still 2000. So, a mixed bag.
In the next chapter, we will examine...