Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to §15.2/2:</p> <blockquote> <p>An object that is partially constructed or partially destroyed will have destructors executed for all of its fully constructed subobjects, that is, for subobjects for which the constructor has completed execution and the destructor has not yet begun execution.</p> </blockquote> <p>So the base class destructor should be called. That is, just like we know this will clean up the base class:</p> <pre><code>#include &lt;iostream&gt; struct foo { ~foo() { std::cout &lt;&lt; "clean" &lt;&lt; std::endl; } }; struct bar : foo { bar() { // foo is initialized... throw 0; // ...so its destructor is run } }; int main() { try { bar b; } catch (...) { std::cerr &lt;&lt; "caught" &lt;&lt; std::endl; } } </code></pre> <p>And that this will clean up the member:</p> <pre><code>#include &lt;iostream&gt; struct foo { ~foo() { std::cout &lt;&lt; "clean" &lt;&lt; std::endl; } }; struct bar { ~bar() { // f has been initialized... throw 0; // ...so its destructor will run } foo f; }; int main() { try { bar b; } catch (...) { std::cerr &lt;&lt; "caught" &lt;&lt; std::endl; } } </code></pre> <p>This will also clean up the base class:</p> <pre><code>#include &lt;iostream&gt; struct foo { ~foo() { std::cout &lt;&lt; "clean" &lt;&lt; std::endl; } }; struct bar : foo { ~bar() { // foo has been initialized... throw 0; // ...so its destructor will run } }; int main() { try { bar b; } catch (...) { std::cerr &lt;&lt; "caught" &lt;&lt; std::endl; } } </code></pre> <p>That's my understanding of the quote.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload