Sorry for the generic title but I can only describe what's going on.
std::unique_ptr<int> qq() {
int b = 11;
std::unique_ptr<int> f(&b);
return f;
}
int main() {
std::unique_ptr<int> q = qq();
int *p = q.release();
*p = 11;
std::cout << *p << "\n";
std::cout << *p << "\n";
return 0;
}
outputs
11
32767 // why not 11?
returning with return std::move(f)
results in an output of
11
0 // why not 11?