https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58487
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:2ae5384d457b9c67586de012816dfc71a6943164 commit r14-1594-g2ae5384d457b9c67586de012816dfc71a6943164 Author: Jason Merrill <ja...@redhat.com> Date: Tue Jun 6 12:46:26 2023 -0400 c++: Add -Wnrvo While looking at PRs about cases where we don't perform the named return value optimization, it occurred to me that it might be useful to have a warning for that. This does not fix PR58487, but might be interesting to people watching it. PR c++/58487 gcc/c-family/ChangeLog: * c.opt: Add -Wnrvo. gcc/ChangeLog: * doc/invoke.texi: Document it. gcc/cp/ChangeLog: * typeck.cc (want_nrvo_p): New. (check_return_expr): Handle -Wnrvo. gcc/testsuite/ChangeLog: * g++.dg/opt/nrv25.C: New test.