Guided Notes

Errors, Debugging & Input Validation

Compile errors vs runtime errors, return codes and errno, validating input with strtol, debugging with gdb and sanitizers, and defensive habits.

Kinds of errors

Slide 1 / 5
KindExampleCaught by
Syntax / compileMissing semicolon, wrong typeThe compiler (read the first error first)
WarningUnused variable, %d with a doublegcc -Wall -Wextra
Runtime crashNULL dereference, divide by zeroRunning, a debugger
Undefined behaviorOut-of-bounds read, signed overflowSanitizers, careful code
LogicWrong formula, off-by-oneTests, printing values
← File Handling