Module 11 · Pointers and Memory
Bug Gallery: NULL, Dangling and the Wild Pointer
ProReading
Bob needs a function that makes a score and hands it back. An old book says returning the address of a local variable works for a while. Bob likes things that work for a while. On the Playground, the Compile output tab turns amber, the badge says Runtime error, and the Output tab says (no output).
Pro lesson
This one goes deeper
It is included with this track and with Learn Pro. Every question on the Skill Test can be answered from the free lessons, so this is depth and never a gate on the certificate.
What is inside Bug Gallery: NULL, Dangling and the Wild Pointer
- Bob's score: the address of a local that died
- The same bug behind an out-parameter
- A block's local dies at its closing brace
- NULL: a crash on the right line
- The wild pointer: an address nobody gave it
- Writing through a cast-away const
- Kenji's walk one box past the end
- The wrong type, and the missing ampersand
- What GCC 12 says, and what it cannot see
- AddressSanitizer and UBSan: catching what actually ran
- The pointer checklist