Skip to content

Commit 97d8538

Browse files
TylerMSFTTylerMSFT
authored andcommitted
some edits
1 parent c6e9b0d commit 97d8538

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

docs/code-quality/c6001.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ int f( bool b )
4949

5050
## Heuristics
5151

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.
5553

5654
```cpp
5755
void init( int& i );
@@ -70,14 +68,9 @@ int f( bool b )
7068
}
7169
```
7270
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.
7572
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:
8174
8275
```cpp
8376
void use( _In_ int& i );
@@ -86,7 +79,7 @@ int f( bool b )
8679
{
8780
int i;
8881
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
9083
9184
if ( b )
9285
{
@@ -96,8 +89,6 @@ int f( bool b )
9689
}
9790
```
9891

99-
[SAL annotations]: ./annotating-function-parameters-and-return-values.md
100-
10192
## See also
10293

10394
[Compiler Warning (level 1 and level 4) C4700](../error-messages/compiler-warnings/compiler-warning-level-1-and-level-4-c4700.md)

0 commit comments

Comments
 (0)