No!
Sometimes programmers think that the [] in the delete[] p only exists
so the compiler will call the appropriate destructors for all elements in the
array. Because of this reasoning, they assume that an array of some built-in
type such as char or int can be deleted without the []. E.g., they
assume the following is valid code:
void userCode(int n)
{
char* p = new char[n];
...
delete p; // ← ERROR! Should be delete[] p !
}
But the above code is wrong, and it can cause a disaster at runtime. In
particular, the code that's called for
delete p is
operator
delete(void*), but the code that's called for
delete[] p is
operator delete[](void*). The default behavior for the latter is to
call the former, but users are allowed to replace the latter with a different
behavior (in which case they would normally also replace the corresponding
new code in
operator new[](size_t)). If they replaced the
delete[] code so it wasn't compatible with the
delete code, and you
called the wrong one (i.e., if you said
delete p rather than
delete[] p), you could end up with a disaster at runtime.