title: Why does the delete[] syntax exist in C++?
body: <p>Every time somebody asks a question about <code>delete[]</code> on here, there is always a pretty general &quot;that's how C++ does it, use <code>delete[]</code>&quot; kind of response.  Coming from a vanilla C background what I don't understand is why there needs to be a different invocation at all.</p>
  <p>With <code>malloc()</code>/<code>free()</code> your options are to get a pointer to a contiguous block of memory and to free a block of contiguous memory.  Something in implementation land comes along and knows what size the block you allocated was based on the base address, for when you have to free it.</p>
  <p>There is no function <code>free_array()</code>.  I've seen some crazy theories on other questions tangentially related to this, such as calling <code>delete ptr</code> will only free the top of the array, not the whole array.  Or the more correct, it is not defined by the implementation.  And sure... if this was the first version of C++ and you made a weird design choice that makes sense.  But why with <code>$PRESENT_YEAR</code>'s standard of C++ has it not been overloaded???</p>
  <p>It seems to be the only extra bit that C++ adds is going through the array and calling destructors, and I think maybe this is the crux of it, and it literally is using a separate function to save us a single runtime length lookup, or <code>nullptr</code> at end of the list in exchange for torturing every new C++ programmer or programmer who had a fuzzy day and forgot that there is a different reserve word.</p>
  <p>Can someone please clarify once and for all if there is a reason besides &quot;that's what the standard says and nobody questions it&quot;?</p>