Skip to content

clang-analyzer-cplusplus.Move not reported for usage after std::move() with range #137157

Open
@firewave

Description

@firewave
#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <string>

int main()
{
    std::list<std::string> l1 = { "1" };

    std::list<std::string> l2;
    std::move(l1.begin(), l1.end(), std::back_inserter(l2));

    std::cout << "l1: " << *l1.cbegin() << '\n'; // <--- should have a use-after-move
    std::cout << "l2: " << *l2.cbegin() << '\n';
}

https://godbolt.org/z/Y96a6nv7h

https://en.cppreference.com/w/cpp/algorithm/move

Also not detected by bugprone-use-after-move clang-tidy check: #137156

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