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
Part I: FoundationsPart II: C and the MachinePart III: Cost and the First DelegationPart IV: C++ and ObjectsPart V: Generic Code, Data Structures, and Agent Teams 1 From Python to C 2 The Working Loop 3 Control Flow, Functi… 4 Pointers 5 Arrays, Strings 6 The Stack and the He… 7 Structs, Headers 8 Growable Arrays and… 9 Files, Bits 10 Complexity and Sorti… 11 Specify First 12 Moving to C++ 13 Classes, Invariants 14 Resource Ownership 15 Inheritance, Polymor… 16 Templates and the St… 17 Binary Search Trees 18 Hash Tables, Excepti… 19 Directing a Team of… 20 A First Look at Conc… 20 chapters63 traps · 51 links

TutorPairTeamAgent trapLines join chapters that cite each other; thicker means more often

The same map as a list

  1. 01 From Python to C: What Python Was Hiding Tutor Memory
  2. 02 The Working Loop Tutor Memory
  3. 03 Control Flow, Functions, Recursion, and Counting Operations Tutor Memory Cost
  4. 04 Pointers Tutor Memory
  5. 05 Arrays, Strings, and Matrices: n, n², n³ Tutor Memory Cost
  6. 06 The Stack and the Heap: Dynamic Memory and Ownership Tutor Memory Ownership
  7. 07 Structs, Headers, and Multi-File Programs Tutor Memory Ownership Interfaces
  8. 08 Growable Arrays and Linked Lists: The Cost of Growth Tutor Ownership Cost
  9. 09 Files, Bits, and Function Pointers: ADTs Behind a Header Tutor Memory Interfaces
  10. 10 Complexity and Sorting: Your First Delegation Pair Cost
  11. 11 Specify First: Abstract Data Types Pair Ownership Interfaces
  12. 12 Moving to C++: Is It Really C++? Pair Memory Cost
  13. 13 Classes, Invariants, and Operator Overloading Pair Interfaces
  14. 14 Resource Ownership: RAII, the Rules of Zero, Three, and Five, and Smart Pointers Pair Ownership
  15. 15 Inheritance, Polymorphism, and Composition: Reviewing an Agent's Design Pair Ownership Interfaces
  16. 16 Templates and the Standard Library Team Cost Interfaces
  17. 17 Binary Search Trees Team Ownership Cost
  18. 18 Hash Tables, Exceptions, and the Search Study Team Cost
  19. 19 Directing a Team of Agents Team Interfaces
  20. 20 A First Look at Concurrency Team Memory Ownership

Which instrument catches what

InstrumentWhat it tells youTraps
Compiler warningsTreat every warning as an error; the flag names the problem before the program runs.7
AddressSanitizerReports out-of-bounds access, use-after-free and stack overflow on the paths a run reaches.16
UndefinedBehaviorSanitizerFlags signed overflow, bad shifts, null loads and other operations with no meaning in C or C++.3
LeakSanitizerLists every heap block no pointer can reach when the program exits.6
ValgrindChecks memory use on a build without sanitizers, including uninitialized reads and lost bytes.5
ThreadSanitizerReports data races between threads, but only on interleavings a run actually hits.3
gdbShows what is in memory and on the stack right now, so you can compare it with your own diagram.2
TestsEdge cases written before the code; a failure proves more than a pass.22
Timing and log-log plotsMeasured cost at increasing n, compared with the bound you derived.12
Build toolsmake, nm, od, git and checksums: the tools that show what was built and what changed.5
Your own traceA 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.