It all depends on the underlying memory manager. Simply put, C ++ requires you to delete arrays with delete[] and delete non-arrays with delete . There is no explanation in the standard of your behavior.
However, it is likely that delete p; just frees a block of memory starting at p (regardless of whether the array is or not). On the other hand, delete[] additionally goes through each element of the array and calls the destructor. Since regular data types, such as char , do not have destructors, the effect does not work, so delete and delete[] ultimately do the same.
As I said, all this is implementation specific. There is no guarantee that delete will work on arrays of any type. It just happens in your case. In C ++, we call this behavior undefined - it may work, maybe not, it can do something completely random and unexpected. Itβs best not to rely on undefined behavior.
source share