[llvm-bugs] [Bug 45872] New: Unclear warning -Wreturn-std-move
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 11 01:40:46 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45872
Bug ID: 45872
Summary: Unclear warning -Wreturn-std-move
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jvapen at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
// https://godbolt.org/z/Fb7vvs
// clang++ -Wreturn-std-move -std=c++17 t.cpp
#include <vector>
auto f() -> std::vector<int>;
auto g(std::vector<int> &) -> void;
auto h() -> std::vector<int>
{
auto v = f();
g(v);
return v;
}
auto i() -> std::vector<int>
{
auto &&v = f(); // WARNING: local variable 'v' will be copied despite
being returned by name
g(v);
return v;
}
--------------------------
The above code gives a warning with return-std-move. However, if we replace
`auto &&` by `auto`, as done in h(), we don't get a warning.
In not familiar enough with the standard to know if this warning is indeed
doing the right thing.
If this is correct, it would be really helpful if the warning message contained
a note explaining what is the reason for this not being copied by name. This
way, the root cause could be tackled instead of the symptom.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200511/e6c9ea81/attachment.html>
More information about the llvm-bugs
mailing list