This seems to be missed by existing stack address check as the address doesn't escape scope of the stack but is preserved between calls using a static variable.
auto f() {
process stack_array[] = { method1, method2, method3 };
static *process process_to_use = nullptr;
if (!process) {
// some expensive init later...
process = &stack_array[n];
}
if (!process) {
process->do_processing(); // segfault
}
}
process_to_use has a stale value when the function is called again. stack_array needs to have static lifetime in this case.