You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/code-quality/c26401.md
+27-5Lines changed: 27 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
1
---
2
2
title: C26401
3
-
ms.date: 07/21/2017
3
+
ms.date: 12/14/2020
4
4
ms.topic: "conceptual"
5
5
f1_keywords: ["C26401"]
6
6
helpviewer_keywords: ["C26401"]
7
7
ms.assetid: b9d3d398-697a-4a5d-8bfe-9c667dffb90b
8
-
description: CppCoreCheck rule that enforces C++ Core Guidelines I.11
8
+
description: CppCoreCheck rule C26401 enforces C++ Core Guidelines I.11
9
9
---
10
10
# C26401 DONT_DELETE_NON_OWNER
11
11
12
-
This check detects places where moving to `owner<T>` can be a good option for the first stage of refactoring. Like C26400 it enforces rules I.11 and R.3, but focuses on the "release" portion of the pointer lifetime. It warns on any call to operator **`delete`** if its target is neither an `owner<T>`nor an implicitly assumed owner. For more information, see [C26400](c26400.md) regarding the **`auto`** declarations. This does include expressions that refer to global variables, formals, and so on.
12
+
This check detects places where moving to `owner<T>` can be a good option for the first stage of refactoring. Like C26400, it enforces rules I.11 and R.3, but focuses on the "release" portion of the pointer lifetime. It warns on any call to operator **`delete`** if its target isn't an `owner<T>`or an implicitly assumed owner. For more information about **`auto`** declarations, see [C26400](c26400.md). This check includes expressions that refer to global variables, formal parameters, and so on.
13
13
14
-
Warnings C26400 and C26401 always occur with [C26409](c26409.md), but they are more appropriate for scenarios where immediate migration to smart pointers is not feasible. In such cases the `owner<T>` concept can be adopted first and C26409 may be temporarily suppressed.
14
+
Warnings C26400 and C26401 always occur with [C26409](c26409.md), but they're more appropriate for scenarios where immediate migration to smart pointers isn't feasible. In such cases, the `owner<T>` concept can be adopted first, and C26409 may be temporarily suppressed.
There's a C++ idiom, `delete this`, that triggers this warning. The warning is intentional, because the C++ Core Guidelines discourage this pattern. You can suppress the warning by using the `gsl::suppress` attribute, as shown in this example:
> `Avoid calling new and delete explicitly, use std::make_unique<T> instead (r.11).`
13
13
14
-
Even if code is clean of calls to`malloc()` and `free()`, we still suggest that you consider better options than explicit use of operators [`new` and `delete`](../cpp/new-and-delete-operators.md).
14
+
Even if code is clean of calls to`malloc` and `free`, we still suggest that you consider better options than explicit use of operators [`new` and `delete`](../cpp/new-and-delete-operators.md).
15
15
16
16
**C++ Core Guidelines**:\
17
17
[R.11: Avoid calling new and delete explicitly](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly)
@@ -22,7 +22,7 @@ The ultimate fix is to use smart pointers and appropriate factory functions, suc
22
22
23
23
- The checker warns on calls to any kind of operator **`new`** or **`delete`**: scalar, vector, overloaded versions (global and class-specific), and placement versions. The placement **`new`** case may require some clarifications in the Core Guidelines for suggested fixes, and may be omitted in the future.
24
24
25
-
## Example
25
+
## Examples
26
26
27
27
This example shows C26409 is raised for explicit **`new`** and **`delete`**. Consider using smart pointer factory functions such as `std::make_unique` instead.
28
28
@@ -35,3 +35,24 @@ void f(int i)
35
35
auto unique = std::make_unique<int[]>(i); // prefer using smart pointers over new and delete
36
36
}
37
37
```
38
+
39
+
There's a C++ idiom, `delete this`, that triggers this warning. The warning is intentional, because the C++ Core Guidelines discourage this pattern. You can suppress the warning by using the `gsl::suppress` attribute, as shown in this example:
Copy file name to clipboardExpand all lines: docs/mfc/reference/clistctrl-class.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,7 +267,7 @@ CSize ApproximateViewRect(
267
267
The proposed dimensions of the control, in pixels. If dimensions are not specified, the framework uses the current width or height values of the control.
268
268
269
269
*iCount*<br/>
270
-
Number of items to be displayed in the control. If this parameter is -1, the framework uses the total number of items currently in the control.
270
+
Number of items to be displayed in the control. Pass -1 to use the total number of items currently in the control.
271
271
272
272
### Return Value
273
273
@@ -3650,7 +3650,7 @@ BOOL SetItemState(
3650
3650
### Parameters
3651
3651
3652
3652
*nItem*<br/>
3653
-
Index of the item whose state is to be set.
3653
+
Index of the item whose state is to be set. Pass -1 to apply the state change to all items.
3654
3654
3655
3655
*pItem*<br/>
3656
3656
Address of an [LVITEM](/windows/win32/api/commctrl/ns-commctrl-lvitemw) structure, as described in the Windows SDK. The structure's `stateMask` member specifies which state bits to change, and the structure's `state` member contains the new values for those bits. The other members are ignored.
0 commit comments