When using a std::map with int for the key the bounds are checked as if it's an array.
std::map<int, std::string=""> myMap = { {1, "1"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}};</int,>
for (int i = 1; i <= 5; ++i) { // Out of bounds access in 'myMap.at(i)', if 'myMap' size is 5 and 'i' is 5 int myInt = myMap.at(i); }
Thanks for reporting, this PR fixes the issue: https://github.com/danmar/cppcheck/pull/4230
Log in to post a comment.
When using a std::map with int for the key the bounds are checked as if
it's an array.
std::map<int, std::string=""> myMap = {
{1, "1"},
{2, "2"},
{3, "3"},
{4, "4"},
{5, "5"}};</int,>
for (int i = 1; i <= 5; ++i)
{
// Out of bounds access in 'myMap.at(i)', if 'myMap' size is 5 and 'i' is
5
int myInt = myMap.at(i);
}
Thanks for reporting, this PR fixes the issue: https://github.com/danmar/cppcheck/pull/4230