#include <iostream>
#include <cassert>

class [[clang::consumable(unconsumed)]] Object {
public:
    Object() {}
    Object(Object&& other) { other.invalidate(); }
    [[clang::callable_when(unconsumed)]]
    void do_something() { assert(m_valid); }

private:
    [[clang::set_typestate(consumed)]]
    void invalidate() { m_valid = false; }
    bool m_valid { true };
};

int main(int, char**) {
    Object object;
    auto other = std::move(object);
    object.do_something();
    return 0;
}

Add example of clang attributes for prevention of use after move.
Add example of clang attributes for prevention of use after move.

Compile with:

clang -Wconsumed move_bugs.cpp -o move_bugs -lstdc++

Warning message is generated during compilation:

move_bugs.cpp:20:12: warning: invalid invocation of method 'do_something' on object 'object' while it is in the 'consumed' state [-Wconsumed]
    object.do_something();
           ^
1 warning generated.
