title: Why is an overloaded delete not called when an exception is thrown in a destructor?
body: <p>I've written the below code which overloads the <code>new</code> and <code>delete</code> operators and throws an exception in the destructor.</p>
  
  <p>When the exception is thrown, why is the code in the <code>delete</code> operator not executed (and "bye" printed)?</p>
  
  <p>If it shouldn't be executed, (how) is the memory freed? Is <a href="http://en.cppreference.com/w/cpp/memory/new/operator_delete" rel="nofollow noreferrer">one of the other <code>delete</code> operators</a> called? Would overloading one of them instead result in the corresponding code being executed? Or is the memory simply not freed because a failed destruction implies that maybe it shouldn't be?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class A
  {
  public:
      A() { }
      ~A() noexcept(false) { throw exception(); }
      void* operator new (std::size_t count)
      {
          cout &lt;&lt; "hi" &lt;&lt; endl;
          return ::operator new(count);
      }
      void operator delete (void* ptr)
      {
          cout &lt;&lt; "bye" &lt;&lt; endl;
          return ::operator delete(ptr);
      }
      // using these (with corresponding new's) don't seem to work either
      // void operator delete (void* ptr, const std::nothrow_t&amp; tag);
      // void operator delete (void* ptr, void* place);
  };
  
  int main()
  {
      A* a = new A();
      try
      {
          delete a;
      }
      catch(...)
      {
          cout &lt;&lt; "eek" &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>hi
  eek
  </code></pre>
  
  <p><a href="http://ideone.com/6GVeXu" rel="nofollow noreferrer">Live demo</a>.</p>
  
  <p>I looked at:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor">throwing exceptions out of a destructor</a></li>
  <li><a href="https://stackoverflow.com/questions/19686769/how-does-c-free-the-memory-when-a-constructor-throws-an-exception-and-a-custom">How does C++ free the memory when a constructor throws an exception and a custom new is used</a></li>
  <li>And others</li>
  </ul>
  
  <p>But I couldn't find an answer to what exactly happens (1) for an exception in the destructor (as opposed to the constructor) and (2) with an overloaded delete.</p>
  
  <p>I don't need a lecture on throwing an exception in a destructor being bad practice - I just ran into similar code and I'm curious about the behaviour.</p>
  
  <hr>
  
  <p>I would prefer an answer supported by the standard or similar references, if such references exist.</p>