Quuxplusone added a comment. Hi, I'm the main original author (although I would not claim "current maintainer") of the Clang warning. Clang doesn't warn about `const vector<int> v; return v;` because in that case, adding `std::move` to the return would not help anything. I had not considered that we might suggest a "fixit" of "Change the declared type of this variable from `vector` to `const vector`"; that sounds like a big non-local change whose correctness would be very difficult to verify. I think (FWIW) that such a fixit would be a very hard sell, but at the same time I admit that I had not even thought of it when I was working on the diagnostic originally.
If you're working in this area, I would also caution you that C++2a is going to completely rewrite the rules in this area. In C++2a, everything that Clang currently warns about is going to be //fixed in the standard//, so that the Clang warning becomes merely part of `-Wc++17-compat`. Nobody is currently working on that Clang patch AFAIK. If you're interested in submitting Clang patches in this area, that might be a very high-value (if kind of fuzzy/user-experience/political) patch to work on! Meanwhile, as of November 2019, the C++2a committee draft still contains unfixed corner cases that Clang doesn't warn about. For example: https://godbolt.org/z/fBKM-4 (no warning from Clang; C++2a fixes this behavior) https://godbolt.org/z/EfBCdQ (no warning from Clang; C++2a does NOT fix this behavior) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70390/new/ https://reviews.llvm.org/D70390 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits