title: std::unique_ptr of base class holding reference of derived class does not show warning in gcc compiler while naked pointer shows it. Why?
body: <p>I have a hierarchy of base class and derived class. Base class has one  virtual function which is overridden by derived class.  </p>
  
  <pre><code>class Base
  {  
  public:  
      ~Base();    
      virtual void other_functionality() = 0;  
  };
  
  class Derived : public Base
  {  
  public:  
      ~Derived ();    
      void other_functionality() {//some code};  
  };
  </code></pre>
  
  <p>Now if i do like this:</p>
  
  <pre><code>int main()
  {
  Base * P = new Derived ();
  delete p;
  return 0;
  }
  </code></pre>
  
  <p>It gives error:<br>
  <strong>deleting object of polymorphic class type which has non-virtual destructor.</strong></p>
  
  <p>But with unique_ptr it passes without warning.</p>
  
  <pre><code>int main()
  {
   std::unique_ptr&lt;Base&gt; p;
   p.reset(new Derived ());
  
  return 0;
  }
  </code></pre>
  
  <p>I know if I use virtual destructor. Warning with naked pointer will be solved. But question remains - why absence of virtual destructor shows problem with naked pointer and not with unique_ptr.</p>