Open Quuxplusone opened 4 years ago
Since I was investigating this, I thought I'd put my links and notes here to
make it easier to understand the history of this.
Oct 23 2012 to Nov 24 2014
https://wg21.cmeerw.net/cwg/issue1579
Changes so 'return id;' where 'id' is automatic can treat 'id' as an xvalue.
Feb 13 2015 to Apr 28 2015
https://reviews.llvm.org/D7633 New warning -Wpessimizing-move to catch when
removing calls to std::move prevent optimization
Added redundant-move diagnostic, DR1579 mentioned
May 18, 2015 to Jul 29 2015
Have -Wredundant-move ignore reference types.
[Sema] Emit correct warning when copy-elision is not possible.
Do not give a -Wredundant-move warning when removing the move will result in an
error.
Disable -Wpessimizing-move and -Wredundant-move in template instantiations.
Jul 29 2015 to Jul 29 2015
https://reviews.llvm.org/D11615 Fix redundant move warning
Effectively removed redundant-move diagnostic, only warns on moving parameters
in return.
Jun 22 2016 to Jun 30 2016
https://reviews.llvm.org/D21619 [Sema] Implement C++14's DR1579: Prefer moving
id-expression out of functions
Implemented DR1579, did not update redundant-move diagnostic
Feb 14 2018 to Apr 12 2018
https://reviews.llvm.org/D43322 Diagnose cases of "return x" that should be
"return std::move(x)" for efficiency
Added return-std-move-in-c++11 diagnostic, warns when c++11 pre CWG1579 should
use std::move.
Aug 20 2018 to Aug 26 2018
https://patches-gcc.linaro.org/patch/8942/
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87029 PR c++/87029, Implement -
Wredundant-move.
gcc implements redundant-move diagnostic, mentions DR1579 and the clang
diagnostic.
Aug 21 2018 to Mar 13 2019
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-01/msg00343.html C++ PATCH for
c++/88692 - -Wredundant-move false positive with *this
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-03/msg00146.html C++ PATCH for
c++/87378 - bogus -Wredundant-move warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89660 PR c++/89660 - bogus error
with -Wredundant-move.
Aug 5 2019 to ???
https://reviews.llvm.org/D65774 Removing redundant-move warnings generated by
gcc9x.
Just to make things more complex, I just discovered
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1825r0.html
https://github.com/cplusplus/draft/issues/3002
The clang (lack of) implementation is documented at
https://clang.llvm.org/cxx_status.html#cxx11 inside the c++11 summary since
it's considered a DR so applies back to c++11 even though it's a c++20 thing.
gcc seems to be tracking implementing it at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91427 .
Which means there is likely to be another round of this '-in-c++11' as '-in-
c++17' madness. And will probably also affect pessimizing-move (note
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89780).
In "D11615 Fix redundant move warning" the redundant-move diagnostic was limited due to clang at the time not implementing CWG1579. Later with "D21619 [Sema] Implement C++14's DR1579: Prefer moving id-expression out of functions" this was implemented, but the redundant-move diagnostic was not updated. In the meantime gcc has implemented a redundant-move diagnostic which does support CWG1579, so the diagnostics are confusingly different without need. Clang's current redundant-move diagnostic would be better named redundant-move-in-c++11.
This is somewhat complicated by the introduction in "D43322 Diagnose cases of "return x" that should be "return std::move(x)" for efficiency" of return-std-move-in-c++11 which is helpful if older toolchains need to be supported. It would be nice if the redundant-move diagnostic were split into redundant-move-in-c++11 and redundant-move since return-std-move-in-c++11 and a full CWG1579 redundant-move are in conflict (by definition).