liveBook · Manning

Chapter 2: Standards, coding guidelines, and memory safety

What you will learn in chapter 2 of Memory Safe C++

This introduction explains why C++ compilation alone cannot ensure safety and how standards, coding guidelines, and independent assessment complement it.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why C++ compilation alone cannot ensure safety and how standards, coding guidelines, and independent assessment complement it.

Key terms: C++ standard, memory safety failures, runtime values, data races, safety standards, coding guidelines, certification, independent assessor, evidence

2.1 The safety standards

This section explains why safety standards are needed and the requirements they share across industries.

Key terms: safety standards, compliance, shared framework, risk classification, Automotive Safety Integrity Level, software safety class, defined development lifecycle, hazard analysis, verification, bidirectional traceability

2.1.1 Automotive — ISO 26262

This section explains automotive functional safety under ISO 26262, how ASIL risk levels affect C++ development, and what MC/DC verification demonstrates.

Key terms: ISO 26262, functional safety, Automotive Safety Integrity Levels, ASIL, QM, severity, V-model, software unit design and implementation, structural coverage, verification independence

2.1.2 Medical devices — IEC 62304

This section explains how IEC 62304 structures medical-device software development around risk-based safety classes.

Key terms: IEC 62304, lifecycle processes, activities, tasks, risk management, ISO 14971, software safety class, Class C, traceability

2.1.3 Railway — EN 50716:2023

This section explains how EN 50716 fits into railway safety standards and governs software integrity and development.

Key terms: fail-safe design, proven-in-use components, independent verification, EN 50716, EN 50126, EN 50129, RAMS, signaling, rolling stock, Basic Integrity

2.1.4 Aerospace — DO-178C

This section introduces DO-178C’s objective-based approach to airborne software assurance, its severity-based assurance levels, and its development and verification processes.

Key terms: DO-178C, objective-based approach, software airworthiness, Development Assurance Level, DAL, failure analysis, ARP4754A/B, planning process, development process, integral processes

2.1.5 Industrial — IEC 61508

This section introduces IEC 61508’s industrial safety scope, risk-based integrity levels, and software requirements.

Key terms: IEC 61508, E/E/PE, safety-related systems, Safety Integrity Level, SIL, failure analysis, formal methods, static analysis, MC/DC coverage, IEC 61508 Part 3

2.2 C++ coding guidelines in practice

This section explains how C++ coding guidelines support certification and compares the major guidelines used in safety-critical projects.

Key terms: safety standards, coding guidelines, static and dynamic analysis, auditable evidence, MISRA C++:2023, AUTOSAR C++14, C++17, safe language subset, CERT C++, Common Weakness Enumeration

2.3 From standards to memory-safe C++

This section connects safety standards, coding guidelines, code, and verification in the effort to prevent memory safety violations.

Key terms: safety standards, coding guidelines, verification, memory safety violations

2.4 Type of memory safety violations

This section introduces spatial and temporal memory safety and notes an alternative, broader classification of memory safety bugs.

Key terms: spatial memory safety, temporal memory safety, complete Memory Safety, type, initialization, data-race safety

2.4.1 Spatial memory safety (The “where” question)

This section explains spatial memory violations, their unpredictable effects, and how explicit bounds checking prevents them.

Key terms: spatial violations, undefined behavior, boundaries, bounds checking, buffer.size(), invalid indices, std::array, operator[], overflow

2.4.2 Temporal memory safety (The “when” question)

This section explains temporal memory violations, their unpredictable effects, and how unique ownership can prevent the illustrated use-after-free while still requiring checks for empty pointers.

Key terms: temporal memory safety, spatial violations, use after free, undefined behavior, optimization, std::make_unique, unique_ptr, ownership, use-after-free

2.4.3 Both dimensions together

This section explains why memory accesses need both spatial and temporal safety and illustrates the two checks in a buffer access.

Key terms: spatial violations, temporal violations, undefined behavior, temporal check, spatial check, std::optional<int>, SensorBuffer

2.5 The two categories of impacts

This section explains the reliability and security impacts of memory safety violations and their relevance to certification and remediation.

Key terms: reliability and stability failures, predictable behavior, certification, security vulnerabilities, attack vector, MISRA C++, CERT C++, remediation, coding standard

2.6 Toward compiler-enforced memory safety

This section explains proposed C++ safety profiles, how they would enforce guarantees, and their current state of development.

Key terms: profile, guaranteed properties, defense-in-depth, compiler-enforced model, subsetting a superset, static analysis, hardened vector, span, pointer arithmetic, unchecked casts

2.7 Summary

Concepts explained in this chapter

← Chapter 1: Real-time and safety-critical software

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.