Skip to content

Commit 2c347d3

Browse files
authored
Use correct warning message for C6201
Incorrectly copied warning message from C6200.
1 parent 6d85b29 commit 2c347d3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/code-quality/c6201.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
description: "Learn more about: C6201"
3-
title: C6201
4-
ms.date: 08/16/2022
2+
description: "Learn more about: Warning C6201"
3+
title: Warning C6201
4+
ms.date: 09/28/2022
55
ms.topic: reference
66
f1_keywords: ["C6201", "INDEX_EXCEEDS_MAX", "__WARNING_INDEX_EXCEEDS_MAX"]
77
helpviewer_keywords: ["C6201"]
88
ms.assetid: eefbbd77-007c-4f28-95f6-6de5ee6a27db
99
---
1010
# Warning C6201
1111

12-
> index '*index*' is out of valid index range '*min*' to '*max*' for possibly stack allocated buffer '*parameter-name*'
12+
> Index '*index-name*' is out of valid index range '*minimum*' to '*maximum*' for possibly stack allocated buffer '*variable*'
1313
14-
This warning indicates that an integer offset into the specified stack array exceeds the maximum bounds of that array, potentially causing stack overflow, random behavior, and/or crashes.
14+
This warning indicates that an integer offset into the specified stack array exceeds the maximum bounds of that array. It may potentially cause stack overflow errors, random behavior, or crashes.
1515

1616
## Remarks
1717

@@ -21,20 +21,20 @@ Code analysis name: INDEX_EXCEEDS_MAX
2121

2222
## Example
2323

24-
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:
24+
The following code generates warning C6201. The **`for`** loop condition exceeds the valid index range for `buff` when it sets `i` to 14, which is one element past the end:
2525

2626
```cpp
2727
void f()
2828
{
2929
int buff[14]; // array of 0..13 elements
30-
for (int i = 0; i <= 14; i++) // i exceeds the index
30+
for (int i = 0; i <= 14; i++) // i == 14 exceeds the bounds
3131
{
32-
buff[i] = 0;
32+
buff[i] = 0; // initialize buffer
3333
}
3434
}
3535
```
3636

37-
To correct both warnings, use correct array size as shown in the following code:
37+
To correct the warning, make sure the index stays in bounds. The following code shows the corrected loop condition:
3838

3939
```cpp
4040
void f()

0 commit comments

Comments
 (0)