Consider
#include <iostream>
struct Foo
{
int* n;
Foo(){n = new int{};}
~Foo(){delete n;}
int& get()
{
int* m = n;
return *m;
}
};
int main()
{
Foo f;
std::cout << f.get();
}
This is a cut-down version of a class that manages a pointer, and has a method that returns a reference to the dereferenced pointer.
Is that defined behaviour?