The form of delete operator shall match the form of new operator used to allocate the memory
The form of delete operator shall match the form of new operator used to allocate the memory..
The delete operator releases a block of memory allocated on the
heap. If you try to access a location on the heap that you did not allocate
previously, a segmentation fault can occur.
If you use the single-object notation for delete on a pointer
that is previously allocated with the array notation for new, the
behavior is undefined.
The issue can also highlight other coding errors. For instance, you perhaps wanted to
use the delete operator or a previous new operator on
a different pointer.
The checker flags a defect when:
You release a block of memory with the delete operator but the
memory was previously not allocated with the new operator.
You release a block of memory with the delete operator using
the single-object notation but the memory was previously allocated as an array with
the new operator.
This defect applies only to C++ source files.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Language Support Library |
| Category: Required, Automated |