Fix #11857 FP constParameterReference with std::map (#5551)

This commit is contained in:
chrchr-github 2023-10-13 18:08:40 +02:00 committed by GitHub
parent ebb877adcc
commit f56677a99d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -6666,9 +6666,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-uninit/>
</arg>
</function>
<function name="std::list::find,std::map::find,std::set::find,std::vector::find,std::unordered_map::find,std::unordered_multimap::find,std::unordered_set::find,std::unordered_multiset::find,std::multiset::find,std::multimap::find">
<function name="std::map::find,std::set::find,std::unordered_map::find,std::unordered_multimap::find,std::unordered_set::find,std::unordered_multiset::find,std::multiset::find,std::multimap::find">
<use-retval/>
<const/>
<returnValue type="iterator"/>
<noreturn>false</noreturn>
<arg nr="1">

View File

@ -2582,6 +2582,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
Library::Container::Action::CHANGE_CONTENT,
Library::Container::Action::CHANGE_INTERNAL,
Library::Container::Action::CLEAR,
Library::Container::Action::FIND,
Library::Container::Action::PUSH,
Library::Container::Action::POP,
Library::Container::Action::RESIZE},

View File

@ -880,6 +880,14 @@ void std_unordered_map_emplace_unnitvar(std::unordered_set<int>& u)
u.emplace(i);
}
int std_map_find_constref(std::map<int, int>& m) // #11857
{
std::map<int, int>& r = m;
std::map<int, int>::iterator it = r.find(42);
int* p = &it->second;
return ++*p;
}
void valid_code()
{
std::vector<int> vecInt{0, 1, 2};