Permalink
Browse files

fix -Wreturn-std-move errors

Summary:
This was exposed by the latest clang with -Wreturn-std-move enabled:
```lang=bash
folly/FBString.h:2487:12: error: local variable 'rhs' will be copied despite being returned by name [-Werror,-Wreturn-std-move]
    return rhs;
           ^~~
folly/test/FBStringTest.cpp:1294:23: note: in instantiation of function template specialization 'folly::operator+<char, std::char_traits<char>, std::allocator<char>, folly::fbstring_core<char> >' requested here
    auto test1 = '\0' + std::move(s1);
                      ^
folly/FBString.h:2487:12: note: call 'std::move' explicitly to avoid copying
    return rhs;
           ^~~
           std::move(rhs)
2 errors generated.
```

Reviewed By: Orvid

Differential Revision: D7776805

fbshipit-source-id: f11ae5a1fc416b8838b8ea74d7f6b488f07cab38
  • Loading branch information...
igorsugak authored and facebook-github-bot committed Apr 26, 2018
1 parent 4e12f97 commit b5105fc5581eef1af2a809b7a3a50ac820e572ae
Showing with 2 additions and 2 deletions.
  1. +2 −2 folly/FBString.h
@@ -2451,7 +2451,7 @@ basic_fbstring<E, T, A, S> operator+(
if (rhs.capacity() >= len + rhs.size()) {
// Good, at least we don't need to reallocate
rhs.insert(rhs.begin(), lhs, lhs + len);
return rhs;
return std::move(rhs);
}
// Meh, no go. Do it by hand since we have len already.
basic_fbstring<E, T, A, S> result;
@@ -2484,7 +2484,7 @@ basic_fbstring<E, T, A, S> operator+(
if (rhs.capacity() > rhs.size()) {
// Good, at least we don't need to reallocate
rhs.insert(rhs.begin(), lhs);
return rhs;
return std::move(rhs);
}
// Meh, no go. Forward to operator+(E, const&).
auto const& rhsC = rhs;

0 comments on commit b5105fc

Please sign in to comment.