Closed JohannesLorenz closed 3 years ago
It took a few google searches to confirm (and a few minutes of a google dev talk), but you're 100% right. I just misunderstood some of the C++ standard when it came to std::move() and g++ is right to raise the warning. Curiously clang doesn't yet emit a warning on my system.
Fix warning: "moving a local object in a return statement prevents copy elision [-Wpessimizing-move]".
return x
andreturn std::move(x)
is the same for a localx
, but the latter makes RVO impossible.