<div dir="ltr">Hi,<div><br></div><div>I came upon this patch as I was looking for a way to get the compiler to warn about any function that is written in a way that thwarts RVO, and I thought that I would suggest that maybe this warning could be generalized to something like "Wpessimizing-no-rvo". In other words, this warning could warn about any function that returns something by value but is written in such a way that Clang (and similarly, any other reasonably competent optimizing compiler) is not able to apply (N)RVO to it. Of course, this would include catching pessimizing uses of std::move in a return statement (which could be part of the diagnostic message as the explanation of what prevented clang from applying RVO).</div><div><br></div><div>I understand that this could be problematic in some ways, and that it's not an option that should be enabled by default or through other all-in-one warnings (-Wall, -Wpedantic, ...), because it could unnecessarily dirty-up a lot of builds if it was. But I think such a general option would be really nice to have, and even if Clang's RVO is still a bit too "dumb" at the moment (as Richard mentioned), it would just make that warning a bit too conservative, which would just lead people to modify their code to make it very easy for any "dumb" compiler to apply RVO to.</div><div><br></div><div>I just thought I would bring that up.<br><div class="gmail_extra"><div class="gmail_signature">Mikael.</div>
</div></div></div>