-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA18-5-3.cpp
More file actions
31 lines (30 loc) · 776 Bytes
/
A18-5-3.cpp
File metadata and controls
31 lines (30 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Rule: A18-5-3
// Source line: 29698
// Original file: A18-5-3.cpp
// $Id: A18-5-3.cpp 289442 2017-10-04 10:57:23Z michal.szczepankiewicz $
#include <cstdint>
void Fn1()
{
std::int32_t* array =
new std::int32_t[10]; // new[] operator used to allocate the
// memory for an array
// ...
delete[] array; // Non-compliant - delete[] operator supposed to be used
}
void Fn2()
{
std::int32_t* object = new std::int32_t{0}; // new operator used to
// allocate the memory for an
// integer type
// ...
delete object; // Non-compliant - delete operator supposed to be used
}
void Fn3()
{
std::int32_t* object = new std::int32_t{0};
std::int32_t* array = new std::int32_t[10];
// ...
delete[] array; // Compliant
delete object;
// Compliant
}