Possible Duplicate:
What can I do with a moved-from object?
After you called std::move
and passed the result to a function, you generally have to assume that accessing the moved object later will result in undefined behavior.
Are there tools that can detect those accesses and warn you. For example:
{
Widget w;
foo(std::move(w));
// w may be undefined at this point
w.doSomething(); // WARN
}
At least, gcc 4.7.2
and clang 3.2
with -Wall
do not complain.
Update: Looking back at this question, the critical point is that the compiler cannot decide whether an object is still valid after it has been moved from. If the proposal N4034: Destructive Move was accepted, I would expect the compiler to have more options (but only if the move is destructive).