Destruction of return value on destructor exception
问题 I have the following code: #include <stdexcept> #include <iostream> struct ok { int _n; ok(int n) : _n(n) { std::cerr << "OK" << n << " born" << std::endl; } ~ok() { std::cerr << "OK" << _n << " gone" << std::endl; } }; struct problematic { ~problematic() noexcept(false) { throw std::logic_error("d-tor exception"); } }; ok boo() { ok ok1{1}; problematic p; ok ok2{2}; return ok{3}; // Only constructor is called... } int main(int argc, char **argv) { try {boo();} catch(...) {} } I see that he