3 Apr
2019
3 Apr
'19
9:54 p.m.
Andrzej Krzemienski wrote:
This is analogous to a (potentially smart) pointer: normally you can call `*p`, but sometimes (on nullptr) it is UB, so you may need to check what state it is in.
If it were analogous you wouldn't be making all these arguments about destructors and stack unwinding. Null pointers aren't only null during stack unwinding or in destructors, they can be null anywhere. So you don't need to partition your functions into "dereferences pointers" and "does not dereference pointers". All functions need to check the pointer for being null before dereferencing it, regardless of whether they are part of normal code, or stack unwinding code.