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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
// 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._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs