2 ms·
You can absolutely cause a pointer to dangle without heap allocation. Pointers can point to the stack too. You also have stuff like iterator invalidation, which
by steveklabnik 6y ago
You can absolutely cause a pointer to dangle without heap allocation. Pointers can point to the stack too. You also have stuff like iterator invalidation, which is sort of a special case of a dangling pointer.
- ajxs 6y agoYou're absolutely right. Pardon me. I should have written the more specific 'use-after-free'.
- Gibbon1 6y agoI do bare metal programming. I have a macro + linker widget called stack_allocated_ptr(x) So I can write guards like if(stack_allocated_ptr(thingie)) { exit_critical_error( "oopies"); }