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/c6001.md
+4-13Lines changed: 4 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,7 @@ int f( bool b )
49
49
50
50
## Heuristics
51
51
52
-
Variables are also considered initialized when they're passed by reference to
53
-
another function. Thus, the following example would also consider `i` to be
54
-
initialized.
52
+
Variables are considered initialized when they're passed by reference to another function. The following example shows that `i` is assumed to be initialized by the function it's passed to.
55
53
56
54
```cpp
57
55
voidinit( int& i );
@@ -70,14 +68,9 @@ int f( bool b )
70
68
}
71
69
```
72
70
73
-
This is to support the pattern of passing a pointer to a variable into
74
-
an initialization function.
71
+
This supports the pattern of passing a pointer to a variable into an initialization function.
75
72
76
-
Since many functions expect pointers to point to initialized data already, this
77
-
heuristic can lead to false negatives. [SAL annotations] such as `_In_` and
78
-
`_Out_` can be used to more precisely describe a function's behavior. For
79
-
example, in the following we call an external function that expects its argument
80
-
to already be initialized and the warning is still generated.
73
+
This heuristic can lead to false negatives because many functions expect pointers that point to initialized data. Use [SAL annotations](annotating-function-parameters-and-return-values.md), such as `_In_` and `_Out_`, to describe the function's behavior. The following example calls a function that expects its argument to be initialized, so a warning is generated:
81
74
82
75
```cpp
83
76
void use( _In_ int& i );
@@ -86,7 +79,7 @@ int f( bool b )
86
79
{
87
80
int i;
88
81
89
-
use(i); // uninitialized variable warning because of _In_ annotation on use
82
+
use(i); // uninitialized variable warning because of _In_ annotation on use() declaration
0 commit comments