title: Segmentation Fault with delete even using virtual destructor
body: <p>I am getting segmentation fault while deleting an objected, being referenced by the pointer of the base class, even when I have declared the destructor virtual!</p>
  
  <p>here is my Code</p>
  
  <pre><code>class Shape
  {
      public:
          virtual ~Shape()
          {
              cout&lt;&lt;"Shape destructor is called!"&lt;&lt;endl;      
          }
  
  };    
  
  class Line : public Shape
  {
      public:
      ~Line()
          {
          cout&lt;&lt;"Line destructor is called!"&lt;&lt;endl;       
      }
  
  };
  
  int main()
  {
  Line myLine;
  Shape* myShapePtr  = &amp;myLine; //Line A
  
  delete myShapePtr;
  }
  </code></pre>
  
  <p>`</p>
  
  <h2>Output</h2>
  
  <p>Line destructor is called!</p>
  
  <p>Shape destructor is called!</p>
  
  <p>./runCP.sh: line 2:  2915 Segmentation fault      ./a.out</p>
  
  <p>I understand that in Line A, the object is getting sliced, and this is the reason,I am getting this error. But, yet I cant figure out how object slicing could cause segmentation fault.</p>
  
  <p>If the object has been sliced, then virtual destructor must not have been called, but here virtual destructor is also called.</p>
  
  <p>Please help me understand this.</p>