Miscellaneous-NoNewWithArraysΒΆ

Do not use new with arrays

Required inputs: IR

The use of new with arrays should be avoided, as there is a lot of potential for error:
  • Buffer overflows are more likely as the size of the array needs to be handled separately from the array
  • Operator delete will not properly free the array, and operator delete[] needs to be used instead.
Instead, use std::vector to manage heap-allocated arrays.

Possible Messages

Key

Text

Severity

Disabled

new_on_array

Use of new operator on array type.

None

False

Options