title: Non-polymorphic derived destructor automatically called through shared_ptr
body: <p>mvce:</p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  struct _A {
      ~_A() {
          cout &lt;&lt; "~_A()" &lt;&lt; endl;
      }
  };
  
  struct A : public _A {
      ~A() {
          cout &lt;&lt; "~A()" &lt;&lt; endl;
      }
  };
  
  int main(int argc, char** argv) {
      {
          shared_ptr&lt;_A&gt; p = make_shared&lt;A&gt;();
      } //~A() called
  
      return 0;
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>~A()
  ~_A()
  </code></pre>
  
  <p>Here the destructors are not virtual but somehow the <code>shared_ptr</code> 'knows' it points to an <code>A</code>. Is this reliable or is this undefined behavior ? I want to know if it is necessary I flag the destructors with virtual in this case - assuming I don't work with raw ptrs.</p>