public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107697] New: -Wredundant-move misses std::move applied to const objects (instead of const references)
@ 2022-11-15 13:42 dangelog at gmail dot com
2022-11-15 14:24 ` [Bug c++/107697] " mpolacek at gcc dot gnu.org
2022-11-15 14:25 ` mpolacek at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: dangelog at gmail dot com @ 2022-11-15 13:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107697
Bug ID: 107697
Summary: -Wredundant-move misses std::move applied to const
objects (instead of const references)
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dangelog at gmail dot com
Target Milestone: ---
Hi,
Consider this testcase:
#include <vector>
using T = std::vector<int>;
void f(T);
void use1(const T t) { f(std::move(t)); }
void use2(const T &t) { f(std::move(t)); }
void use3() {
const T t;
f(std::move(t));
}
Currently -Wredundant-move warns only for case 2. But in all three cases
std::move is actually not doing anything good (copy constructor is always
selected). It would be nice if they all were diagnosed.
If I change `f` to `void f(const T &)` then there's no warning at all. I'm
thinking that probably this case should be diagnosed as well.
Clang-tidy's performance-move-const-arg diagnoses them all.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/107697] -Wredundant-move misses std::move applied to const objects (instead of const references)
2022-11-15 13:42 [Bug c++/107697] New: -Wredundant-move misses std::move applied to const objects (instead of const references) dangelog at gmail dot com
@ 2022-11-15 14:24 ` mpolacek at gcc dot gnu.org
2022-11-15 14:25 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-11-15 14:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107697
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Keywords| |diagnostic
Ever confirmed|0 |1
CC| |mpolacek at gcc dot gnu.org
Last reconfirmed| |2022-11-15
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. Currently the code does only:
/* Also try to warn about redundant std::move in code such as
T f (const T& t)
{
return std::move(t);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/107697] -Wredundant-move misses std::move applied to const objects (instead of const references)
2022-11-15 13:42 [Bug c++/107697] New: -Wredundant-move misses std::move applied to const objects (instead of const references) dangelog at gmail dot com
2022-11-15 14:24 ` [Bug c++/107697] " mpolacek at gcc dot gnu.org
@ 2022-11-15 14:25 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-11-15 14:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107697
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I guess this is GCC 14 material at this point.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-15 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15 13:42 [Bug c++/107697] New: -Wredundant-move misses std::move applied to const objects (instead of const references) dangelog at gmail dot com
2022-11-15 14:24 ` [Bug c++/107697] " mpolacek at gcc dot gnu.org
2022-11-15 14:25 ` mpolacek at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).