[Bug c++/89780] -Wpessimizing-move is too agressive with templates and recommends pessimization
herring at lanl dot gov
gcc-bugzilla@gcc.gnu.org
Thu Aug 11 18:01:43 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89780
--- Comment #8 from S. Davis Herring <herring at lanl dot gov> ---
I looked at P2266R3 again; it claims that the conversion function case (in #7)
is actually covered by P1825R0. I think that case is questionable, since it
still refers to "overload resolution to select the constructor for the copy"
and there's no constructor involved when a conversion function is used. (In
particular, it isn't the case that the A object is converted to a Dest
temporary that is then used as the argument to Dest(Dest&&), since that would
be a second user-defined conversion.) If we consider the intent in P1155R3,
though, it's pretty clear that that's just a wording oversight, so it's not
unreasonable that GCC and Clang (but not ICC) accept
template Dest withMove<A>();
in C++20 mode. That means that we don't have to distinguish C++20 and C++23
for this discussion (at least outside of weirder cases like returning a
reference).
More information about the Gcc-bugs
mailing list