[PATCH] New warning -Wpessimizing-move to catch when removing calls to std::move in return statements will result in NRVO

Richard Trieu rtrieu at google.com
Wed Feb 18 18:36:35 PST 2015


So then something like this:

  struct S{};
  S test(bool cond) {
    S s1, s2;
    if (cond)
      return std::move(s1);
    return std::move(s2);
  }

would be better with the std::move's removed:

  struct S{};
  S test(bool cond) {
    S s1, s2;
    if (cond)
      return s1;
    return s2;
  }

even though NRVO would not be triggered since different local variables are used?


http://reviews.llvm.org/D7633

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list