2 Standards, coding guidelines, and memory safety
This chapter covers
- Why safety standards and coding guidelines exist, and how they connect to your C++ code
- The two dimensions of memory safety violations
- Why memory safety violations matter for both reliability and security
- What compiler-enforced memory safety could look like with C++ Profiles direction
Safety-critical systems cannot rely on C++ alone to achieve safety. The compiler checks that your program conforms to the C++ standard, but memory safety failures like use-after-free, buffer overruns, and data races depend on runtime values and on the order in which threads run, neither of which the compiler can see, so it typically stays silent. Something outside the language has to draw the line. In the industries where a software defect can cause serious harm, safety standards, coding guidelines, and independent assessment or certification of the evidence work together to draw that line. Safety standards are the domain's process framework for developing, verifying, and documenting safety-critical systems. Coding guidelines are where those abstract demands become concrete enough for a tool, or a disciplined reviewer, to check. They are catalogs of rules about what a C++ source file is allowed to contain and what it must never do. In certification, an independent assessor inspects the evidence you produced while following the standard and, if it holds up, attests that your system is fit to ship into a regulated market.