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
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:
25
25
26
26
```cpp
27
-
int buff[14]; // array of 0..13 elements
28
27
voidf()
29
28
{
29
+
int buff[14]; // array of 0..13 elements
30
30
for (int i = 0; i <= 14; i++) // i exceeds the index
31
31
{
32
-
buff[i] = 0; // warning C6200
32
+
buff[i] = 0;
33
33
}
34
34
}
35
35
```
36
36
37
37
To correct both warnings, use correct array size as shown in the following code:
38
38
39
39
```cpp
40
-
int buff[14]; // array of 0..13 elements
41
40
voidf()
42
41
{
42
+
int buff[14]; // array of 0..13 elements
43
43
for (int i = 0; i < 14; i++) // i == 13 on the final iteration
0 commit comments