In this code, I reference the local variable b even though it is out of scope. But I do it from within the same function so it\'s probably still on the stack, r
No, that's not guaranteed to work. a is dangling once the inner scope is exited, so any dereference of it results in Undefined Behaviour and nothing whatsoever is guaranteed.