TEST_CASE("erase from set, return result from erase", "[cppcheck][false-positive]")
{
static std::set<int> a_set;
for (auto it = a_set.begin(); it != a_set.end(); ++it)
if (*it == 42)
return a_set.erase(it);
return a_set.end();
}</int>
The line "return a_set.erase(it);" triggers the error.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
TEST_CASE("erase from set, return result from erase", "[cppcheck][false-positive]")
{
static std::set<int> a_set;
for (auto it = a_set.begin(); it != a_set.end(); ++it)
if (*it == 42)
return a_set.erase(it);
return a_set.end();
}</int>
The line "return a_set.erase(it);" triggers the error.
Thanks. I have created a ticket here: https://trac.cppcheck.net/ticket/10151