Skip to content

clang-analyzer-alpha.cplusplus.MismatchedIterator false positive with container insertion #132010

@firewave

Description

@firewave
#include <list>
#include <unordered_set>

void f()
{
    std::list<int> l;
    std::unordered_set<int> us;
    us.insert(l.cbegin(), l.cend());
}
<source>:8:5: warning: Container accessed using foreign iterator argument [clang-analyzer-alpha.cplusplus.MismatchedIterator]
    8 |     us.insert(l.cbegin(), l.cend());
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:8:5: note: Container accessed using foreign iterator argument
    8 |     us.insert(l.cbegin(), l.cend());
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

https://godbolt.org/z/arhEMh6Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions