Skip to content

MoveChecker causes false positives with no way to fix #46

Closed as not planned
@mattiasj-axis

Description

@mattiasj-axis

As a dumb example

#include <utility>
struct Foo {
    Foo() {}
    Foo(Foo&&o) { o._is_valid = false; }
    bool is_valid() { return _is_valid; }
private:
    bool _is_valid = true;
};

int main() {
    Foo a;
    Foo b{std::move(a)};

    if (a.is_valid()) { return 0; } else { return 1; }
}

Where is_valid is actually a check if this object is usable, the MoveChecker is hardcoded to assume that this function must be called [is]empty. This should presumably be an attribute, such as clang::movesafe so that functions that are coded movesafe can be tagged properly.

Likewise, clang::movestatereset or something like such should be introduced for functions that reset the state (but I haven't had that issue, yet).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions