When using a std::map with int for the key the bounds are checked as if it's an array. Tested on 2.8.
std::map<int, std::string> myMap = { {1, "1"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}}; 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); }
Fixed in 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. Tested on 2.8.
Fixed in https://github.com/danmar/cppcheck/pull/4230