Skip to content

Commit 064d394

Browse files
authored
Add example for C26409
1 parent c9741f7 commit 064d394

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/code-quality/c26409.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@ The ultimate fix is to start using smart pointers with appropriate factory funct
1818
## Remarks
1919

2020
- The checker warns on calls to any kind of operator **`new`** or **`delete`**: scalar, vector, overloaded versions (global and class-specific), as well as on placement versions. The latter case may require some clarifications on the Core Guidelines in terms of suggested fixes and may be omitted in the future.
21+
22+
# Example
23+
```cpp
24+
25+
void f(int i)
26+
{
27+
int* arr = new int[i]{}; // C26409, warning is issued for all new calls
28+
delete[] arr; // C26409, warning is issued for all delete calls
29+
30+
auto unique = std::make_unique<int[]>(i); // prefer using smart pointers over new and delete
31+
}
32+
```

0 commit comments

Comments
 (0)