Every tool for finding a bug
Compiler errors and warnings, static analyzers, sanitizers, the debugger and tests. What each one sees, and which to reach for first.
Start with the cheapest tool that could see the bug, and move right only when it can't.
- The build fails → read the first
error:(a template error is the same skill with more notes). - A single-line slip (a read of an unset variable,
=for==, signed compared with unsigned) → compiler warnings, free on every build. - A library rule broken (use after move, a needless copy) → a static analyzer such as clang-tidy.
- Anything that depends on run-time data or timing (reading past the end, use after free, overflow, a data race) → a sanitizer build, running your tests.
- A wrong answer with no rule broken, or "who changed this value?" → the debugger, with breakpoints and watchpoints.
- Keeping it fixed → a test that failed before the fix.
Before the program runs
While it runs
So it stays fixed
Section
Why automated tests
Section