title: how are `delete[] obj` and `delete obj` implemented at compiler level
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1913853/why-is-used-in-delete-delete-to-free-dynamically-allocated-array">Why [] is used in delete ( delete [] ) to free dynamically allocated array?</a><br>
    <a href="https://stackoverflow.com/questions/10999985/why-does-c-still-have-a-delete-and-a-delete-operator">Why does C++ still have a delete[] AND a delete operator?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm wondering what's their difference and I know the obvious answer some might say, that one is to delete an array and the other is to delete a single object but I'm wondering why should there be two different deletion methods for these two operations? I mean delete is basically implemented using C <code>free</code> method which doesn't care if the pointer is actually pointing toward an array or a single object. The only reason I can think of is two be able to know if it's an array and call destructor for each cell instead of only the first object but that wouldn't also be possible since compiler can not guess the length of array just looking at it's pointer. By the way though it's said to invoke undefined behavior to call <code>delete</code> for  memory allocated with <code>new[]</code> I can't imagine anything that could possibly go wrong.</p>