Leaks

Here's a similar situation to Pointing arguments but the function is destructing the object and cleaning after itself.

In this example it will not succeed

#include <iostream> struct SimpleStruct { int bar; }; void foo(SimpleStruct* s) { std::cout << s->bar << std::endl; delete s; s = nullptr; } int main(int argc, char const *argv[]) { SimpleStruct* x = new SimpleStruct; x->bar = 42; foo(x); if (x) std::cout << x->bar << std::endl; return 0; }