This rule finds delete[] expressions that are using a pointer that points to memory allocated using the new operator. Behavior in such cases is undefined and should be avoided.

The new operator allocates memory for just one object, then calls that object's constructor, and delete does the opposite. The array delete[] operator, however, expects the pointer to be pointing to the first element of an array (which could have header data specifying the length of the array) and would attempt to call the destructor on each element of the 'array', which would likely lead to a segfault due to the invalid header data.

Use the delete operator when freeing memory allocated with new.

  • S. Meyers. Effective C++ 3d ed. pp 73-75. Addison-Wesley Professional, 2005.