https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89660

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Untested patch:

--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -9433,10 +9433,12 @@ maybe_warn_pessimizing_move (tree retval, tree
functype)
        }
      /* Warn if the move is redundant.  It is redundant when we would
         do maybe-rvalue overload resolution even without std::move.  */
-     else if (treat_lvalue_as_rvalue_p (arg, /*parm_ok*/true))
+     else if (warn_redundant_move
+          && treat_lvalue_as_rvalue_p (arg, /*parm_ok*/true))
        {
          /* Make sure that the overload resolution would actually succeed
         if we removed the std::move call.  */
+         cp_unevaluated e;
          tree t = convert_for_initialization (NULL_TREE, functype,
                           move (arg),
                           (LOOKUP_NORMAL

Reply via email to