Q:

Assigning to a variable which was moved in right side of expression

Is this undefined behavior or not?
std::unique_ptr<T> p = some_function();

p = some_other_function(std::move(p));

I've read http://en.cppreference.com/w/cpp/language/eval_order but not found definitive answer there.

A:

If you search for assignment then you will find rule 8 with only mentions the built-in assignment operator, and std::unique_ptr do overload the assignment operator.
But since the operator is overloaded, the statement
p = some_other_function(std::move(p));

is actually a function call:
p.operator=(some_other_function(std::move(p)));

which makes it part of rule 3 instead. And that makes it well-defined (because std::move(p) have to be done before some_other_function is called, and some_other_function have to finish before p.operator= is called).

A:

The behavior is defined.
std::move(p) is sequenced before the function call some_other_function(), therefore the assignment to p takes place after std::move(p) (it doesn't matter if the assignment operator is built-in or not because there are no side effects other than assigning p).

