Why exceptions from unique_ptr destructor terminates the program?
<p>Take a look at this code which causes program to terminate without catching the exception.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;memory&gt;
#include &lt;stdexcept&gt;
using namespace std;

struct test {
  ~test() noexcept(false) {
    throw runtime_error("-my-cool-exception-");
  }
};

int main()
{
  try {
    auto ptr = unique_ptr&lt;test&gt;(new test());
    //test t; // this is ok, without unique_ptr&lt;test&gt; it works fine.
  }
  catch(exception&amp; e) {
    cout &lt;&lt; "this is not called, the program is aborted";
    cout &lt;&lt; e.what() &lt;&lt; endl;
  }
  return 0;
}
</code></pre>

<p>This question is different from stack overflow question: <a href="https://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor">throwing exceptions out of destructor</a>.</p>

<p>The difference is that only when I use <code>unique_ptr&lt;test&gt;</code> the exception is not caught. </p>

<p>You can see the live code, edit and compile here <a href="http://cpp.sh/9sk5m">http://cpp.sh/9sk5m</a></p>