title: During Segmentation fault can destructor called
body: <p>Hi friend i have one query during program execution if segmentation fault occurs ,can the destructor of automatic created object called.
  i am writing one code and intentionally creating segmentaion fault to check destructor willbe called or not it is not calling .</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  class hello
  {
      public:
      int b;
  };
  
  class test
  {
      public :
          hello *ptr;
          int a;
          void function()
              {
                  ptr = new hello;
  
              }
  
          test()
          {
              cout&lt;&lt;"constructor called"&lt;&lt;endl;
          }
  
          ~test()
          {
              cout&lt;&lt;"destructor called"&lt;&lt;endl;
              delete ptr;
          }
  };
  
      int main()
      {
          test obj;
          obj.function();
          obj.a = 500;
  
          test *ptr ;
          ptr-&gt; a = 900;       //To create segmentation fault
  
      }
  </code></pre>
  
  <p>output:
  constructor called</p>
  
  <p>destructor is not being called.
  so i am not able to delete any object created using "new" inside destructor</p>