Is stack unwinding with exceptions guaranteed by c++ standard? : <p>Concerning the stack unwinding, the c++ standard says:  </p>

<blockquote>
  <p>An exception is considered uncaught after completing the initialization of the exception object ([except.throw]) until completing the activation of a handler for the exception ([except.handle]). This includes stack unwinding.   </p>
</blockquote>

<p>at <a href="http://eel.is/c++draft/except#uncaught-1">par 15.5.3</a> of the current standard. I was trying to understand what the latest sentence (<code>This includes stack unwindings</code>) is referring to:</p>

<ul>
<li>is it supposed that the compiler must take care of unwinding the stack?</li>
<li>or, is it saying that it is compiler-dependent whether to unwind or not the stack?</li>
</ul>

<p>The question arises from the following snippet:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;exception&gt;

struct S{
    S() { std::cout &lt;&lt; " S constructor" &lt;&lt; std::endl; }
    virtual ~S() { std::cout &lt;&lt; " S destructor" &lt;&lt; std::endl; }
};

void f() {
    try{throw(0);}
    catch(...){}
}

void g() {
    throw(10);
}

int main() {
    S s;
    f();
    //g();
}
</code></pre>

<p>Now: </p>

<ol>
<li>if you run it as-is (catching the exception), you have a hint of the stack unwinding</li>
<li>if you comment <code>f();</code> and uncomment <code>g();</code> (not catching the exception), you have hint of stack not being unwound</li>
</ol>

<p>So, the two experiments seem to be in favor of the first bullet above; both clang++ and g++ agree on the result (but it is not a discriminant). </p>

<p>Also, it seems to me very strange that the standard, which is really careful in specifying the object <em>live time</em> and <em>duration</em> is leaving a shadow here.</p>

<p>May anyone clarify? Is stack unwinding for uncaught exceptions guaranteed by the standard? If yes, where? If not, why?</p>
