Technically, the source code is safe in this tiny example. But the reality is that even if you look at Foo funny, you will call UB. It is so terribly dangerous that it is completely not worth it. Just use swap, like everyone else - there is a reason for this, and this is because it is the right choice. Also, homing checks are bad.
Puppy
source share