Skip to content

Instantly share code, notes, and snippets.

@orgads
Last active September 7, 2017 19:50
Show Gist options
  • Select an option

  • Save orgads/0f8dcec8afa734f46527bc6dee726de8 to your computer and use it in GitHub Desktop.

Select an option

Save orgads/0f8dcec8afa734f46527bc6dee726de8 to your computer and use it in GitHub Desktop.
int test(bool condition)
{
int Arr1[3] = {0};
int Arr2[6] = {0};
int *Arr;
int ArrSize;
if (condition)
{
Arr = Arr1;
ArrSize = 3;
}
else
{
Arr = Arr2;
ArrSize = 6;
}
return Arr[ArrSize-1]; // error: Cppcheck(arrayIndexOutOfBounds): Array 'Arr1[3]' accessed at index 5, which is out of bounds.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment