The limits of modern C++
Let’s assume for a moment that we use only STL collections, we avoid pointers, and when we really need them, we use the smart pointers implemented in the standard library, and we write our types with memory safety in mind. Are we done?
Herb Sutter, one of the well-known members of the C++ standardization committee, has looked at this issue and at the more general issue of avoiding security issues in C++, in a blog post titled C++ safety, in context (https://herbsutter.com/2024/03/11/safety-in-context/) published on March 11, 2024. His conclusion is that it’s too easy to write C++ code that by default has security and safety vulnerabilities. The article identifies four areas that need more attention: types, bounds, initialization, and lifetime. Then, he states that there are already some mechanisms in place in C++ 20: span
, string_view
concepts, and bound-aware ranges. What is missing from the language, as the article discusses next, is safety...