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| Kind | Example | Caught by |
|---|---|---|
| Syntax / compile | Missing semicolon, wrong type | The compiler (read the first error first) |
| Warning | Unused variable, %d with a double | gcc -Wall -Wextra |
| Runtime crash | NULL dereference, divide by zero | Running, a debugger |
| Undefined behavior | Out-of-bounds read, signed overflow | Sanitizers, careful code |
| Logic | Wrong formula, off-by-one | Tests, printing values |
