Open
Description
#include <list>
class C
{
public:
C(const std::list<int> &files)
: mFiles(files)
{
mItNextFile = mFiles.begin();
}
bool func() {
if (mItNextFile != mFiles.end()) {
++mItNextFile;
return true;
}
return false;
}
private:
const std::list<int> &mFiles;
std::list<int>::const_iterator mItNextFile;
};
static void f(C *c)
{
while (c->func()) {}
}
<source>:13:13: warning: Iterators of different containers used where the same container is expected [clang-analyzer-alpha.cplusplus.MismatchedIterator]
13 | if (mItNextFile != mFiles.end()) {
| ^
<source>:28:5: note: Loop condition is true. Entering loop body
28 | while (c->func()) {}
| ^
<source>:28:12: note: Calling 'C::func'
28 | while (c->func()) {}
| ^~~~~~~~~
<source>:13:13: note: Iterators of different containers used where the same container is expected
13 | if (mItNextFile != mFiles.end()) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~