Map
The map of the book
C and C++ do not come in separate pieces. A pointer bug in Chapter 4 becomes a leak in Chapter 6, a dangling iterator in Chapter 16 and a data race in Chapter 20. This wheel shows all 20 chapters, the five parts and three phases they fall into, the 63 traps agents have been seen to fall into, and the 51 pairs of chapters that lean on each other most. Click a chapter or a trap to follow the threads.
Thread
Phase
TutorPairTeamAgent trapLines join chapters that cite each other; thicker means more often
The same map as a list
- 01 From Python to C: What Python Was Hiding Tutor Memory
- 02 The Working Loop Tutor Memory
- 03 Control Flow, Functions, Recursion, and Counting Operations Tutor Memory Cost
- 04 Pointers Tutor Memory
- 05 Arrays, Strings, and Matrices: n, n², n³ Tutor Memory Cost
- Pre-2011 string code:
strcpy,strcat,sprintf, bare%s,strncpyas "safe" - Buffers sized without the terminator;
<=loops;>where>=belongs - Matrix loops whose inner index walks down a column of a row-major array
- Happy-path numerics: no iteration cap, overflow "detected" after it happens, no check of n
- Pre-2011 string code:
- 06 The Stack and the Heap: Dynamic Memory and Ownership Tutor Memory Ownership
- 07 Structs, Headers, and Multi-File Programs Tutor Memory Ownership Interfaces
- 08 Growable Arrays and Linked Lists: The Cost of Growth Tutor Ownership Cost
- 09 Files, Bits, and Function Pointers: ADTs Behind a Header Tutor Memory Interfaces
- 10 Complexity and Sorting: Your First Delegation Pair Cost
- 11 Specify First: Abstract Data Types Pair Ownership Interfaces
- 12 Moving to C++: Is It Really C++? Pair Memory Cost
- 13 Classes, Invariants, and Operator Overloading Pair Interfaces
- 14 Resource Ownership: RAII, the Rules of Zero, Three, and Five, and Smart Pointers Pair Ownership
- 15 Inheritance, Polymorphism, and Composition: Reviewing an Agent's Design Pair Ownership Interfaces
- 16 Templates and the Standard Library Team Cost Interfaces
- 17 Binary Search Trees Team Ownership Cost
- 18 Hash Tables, Exceptions, and the Search Study Team Cost
- 19 Directing a Team of Agents Team Interfaces
- 20 A First Look at Concurrency Team Memory Ownership
Which instrument catches what
| Instrument | What it tells you | Traps |
|---|---|---|
| Compiler warnings | Treat every warning as an error; the flag names the problem before the program runs. | 7 |
| AddressSanitizer | Reports out-of-bounds access, use-after-free and stack overflow on the paths a run reaches. | 16 |
| UndefinedBehaviorSanitizer | Flags signed overflow, bad shifts, null loads and other operations with no meaning in C or C++. | 3 |
| LeakSanitizer | Lists every heap block no pointer can reach when the program exits. | 6 |
| Valgrind | Checks memory use on a build without sanitizers, including uninitialized reads and lost bytes. | 5 |
| ThreadSanitizer | Reports data races between threads, but only on interleavings a run actually hits. | 3 |
| gdb | Shows what is in memory and on the stack right now, so you can compare it with your own diagram. | 2 |
| Tests | Edge cases written before the code; a failure proves more than a pass. | 22 |
| Timing and log-log plots | Measured cost at increasing n, compared with the bound you derived. | 12 |
| Build tools | make, nm, od, git and checksums: the tools that show what was built and what changed. | 5 |
| Your own trace | A hand trace or a board drawing of memory, made before you look at any output. | 11 |
Traps come from Appendix B of the book, where each row also has a column for the date and result of re-testing it against the agent you use.