Overview

1 Real-time and safety-critical software

Safety-critical software is any software whose failure can cause serious harm, and in such systems correctness is not optional because lives, equipment, and the environment may depend on every decision the program makes. The chapter uses real incidents to show that failures can cascade from a small defect into major consequences, especially when software is embedded in complex systems of sensors, hardware, and human oversight. It emphasizes that these systems must be engineered with documented evidence of assurance, traceability, compliance, and verification rather than with “it seems to work” confidence.

The chapter then explains that many safety-critical systems are also real-time systems, meaning they must produce correct answers within bounded, provable time limits. In these settings, a late answer can be just as dangerous as a wrong one, because the physical world keeps moving while the program runs. Examples such as emergency braking, flight control, medical devices, industrial control, and railway signaling illustrate the same core challenge: the system must be both accurate and predictable, often under hard deadlines and adverse conditions.

Finally, the chapter makes the case for C++ as a dominant language in these domains because it offers performance, control, and an established ecosystem of certified tools and standards. At the same time, it highlights the language’s central paradox: C++ can support memory-safe designs, but it also allows dangerous memory errors, undefined behavior, and silent corruption to compile cleanly. To manage this, the chapter introduces a memory-safety triad of culture, knowledge, and discipline, supported by static analysis, sanitizers, reviews, and a structured learning process that will be used throughout the book.

Five characteristics that distinguish safety-critical software from conventional software. Each one requires documented evidence, not just working code.
Mapping systems by real-time and safety-critical constraints. Systems in the top-right quadrant face both simultaneously: they must be correct and meet strict timing guarantees. Chemotherapy dosing and aircraft load-and-balance calculation are safety-critical but not real-time; a person checks the numbers before anyone acts on them, so timing is not a safety concern. Video streaming is real-time but not safety-critical; a buffer underrun is frustrating, not fatal.
The real-time safety-critical loop in an automatic emergency braking (AEB) system. The loop begins when an event occurs (a child in the road). Sensors capture the scene and feed data through preprocessing and fusion. The system detects objects, predicts trajectories, and calculates time-to-collision (TTC). If TTC falls below a safe threshold (for example, approximately 1.2 seconds), the system commands the actuators to brake. At 60 km/h, the vehicle travels 1.7 meters every 100 milliseconds, so a missed deadline means a potential collision.
The C++ safety paradox. C++ provides modern safe features and allows dangerous patterns simultaneously. Both paths lead to the same conclusion.
The memory safety triad. All three foundations must be present for the process to work. Remove any one, and memory bugs find their way through.
The memory safety process. Each stage exists to catch what the previous one cannot.
The Complete Learning Cycle (CLC)

Summary

  • Real-time safety-critical systems must respond within strict deadlines; a missed deadline can be as dangerous as a wrong answer.
  • C++ dominates safety-critical development because it offers deterministic execution, zero-cost abstractions, and a mature certification ecosystem.
  • The C++ safety paradox: the language chosen to protect lives is also the leading source of life-threatening bugs.
  • Memory safety is a concern for all C++ software; in safety-critical systems the same defects can cause irreversible harm.
  • Building memory-safe C++ requires a systematic process: safe design patterns, static analysis, dynamic analysis, and code review.
  • Safe C++ depends on knowledge, discipline, and culture. This book provides the first.

FAQ

What makes software “safety-critical”?Software is safety-critical when its failure could cause serious harm such as death, injury, equipment destruction, environmental damage, or cascading failures in connected systems. In these systems, correctness must be demonstrated before release because the consequences of failure are physical, not just financial.
How is real-time safety-critical software different from ordinary safety-critical software?Real-time safety-critical software must be both correct and able to respond within guaranteed, provable time limits. In these systems, a correct result that arrives too late can be as dangerous as an incorrect result.
Why is timing considered part of correctness in real-time systems?Because the physical world keeps changing while software runs, an answer that was valid when data was captured may no longer be valid when it is delivered. If a deadline is missed, the computation may be functionally right but still fail the safety requirement.
Why do safety-critical systems require more than just working code?They require documented, independent evidence that safety requirements were met. That evidence includes assurance, traceability, compliance with standards, and verification through testing, analysis, or formal methods.
What are the main characteristics that distinguish safety-critical software?The chapter highlights correctness, assurance, traceability, compliance, and verification. Together, these show that the software is not only functional, but also justified by evidence and aligned with safety standards.
Why is C++ so widely used in safety-critical development?C++ is popular because it combines high performance, predictable execution, and a mature ecosystem. It is also widely known by engineers and supported by certified compilers, static-analysis tools, and established industry standards.
What is the “C++ safety paradox”?The paradox is that C++ can be used to write memory-safe code, but it also allows dangerous patterns that can bypass those protections. In other words, C++ offers safety features, but it does not enforce them by default.
Why is memory safety so important for all C++ developers, not just safety-critical ones?Because memory bugs can compile cleanly, pass tests, and still cause silent corruption or delayed failures. Even in non-safety-critical software, these defects can create severe operational, financial, or security problems.
What is the memory safety triad in C++?The triad consists of culture, knowledge, and discipline. A team needs a safety-focused culture, knowledge of common memory hazards, and the discipline to apply safe practices consistently under pressure.
What tools are needed to build memory-safe C++ for safety-critical systems?The chapter recommends a C++ compiler, Bazel, Git, static analysis tools like Clang-Tidy, and dynamic analyzers such as AddressSanitizer, UndefinedBehaviorSanitizer, and ThreadSanitizer. It also mentions certified tooling and coding standards like MISRA C++ and SEI CERT C++.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Memory Safe C++ ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Memory Safe C++ ebook for free