Skip to content

Commit 8cdc31e

Browse files
Updated C6201
Example now correctly shows a stack array
1 parent d847198 commit 8cdc31e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/code-quality/c6201.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ Code analysis name: INDEX_EXCEEDS_MAX
2424
The following code generates this warning. This issue stems from the **`for`** loop exceeding the index range, attempting to access the index 14 (the 15th element) when the index 13 (the 14th element) is the last:
2525

2626
```cpp
27-
int buff[14]; // array of 0..13 elements
2827
void f()
2928
{
29+
int buff[14]; // array of 0..13 elements
3030
for (int i = 0; i <= 14; i++) // i exceeds the index
3131
{
32-
buff[i] = 0; // warning C6200
32+
buff[i] = 0;
3333
}
3434
}
3535
```
3636

3737
To correct both warnings, use correct array size as shown in the following code:
3838

3939
```cpp
40-
int buff[14]; // array of 0..13 elements
4140
void f()
4241
{
42+
int buff[14]; // array of 0..13 elements
4343
for (int i = 0; i < 14; i++) // i == 13 on the final iteration
4444
{
4545
buff[i]= 0; // initialize buffer

0 commit comments

Comments
 (0)