I\'ve read a lot about the Visual Studio Code Analysis warning C8386, but can\'t figure out this particular issue with my code. I\'ve reduced it to the following small progr
Since nNumItems is global, it would appear that code analyzer thinks that nNumItems might be set to SIZE_MAX elsewhere before your code executes. You can see this with a sample like:
size_t nNumItems = 0;
void foo()
{
nNumItems = SIZE_MAX;
}
void bar()
{
const size_t nTotal = 3 + 2 * nNumItems;
auto nWords = new int[nTotal];
nWords[0] = 1;
nWords[1] = 2;
}
int main()
{
foo();
bar();
return 0;
}
Perhaps the best fix is to side-step the entire problem by using std::vector.