https://llvm.org/bugs/show_bug.cgi?id=25640
Bug ID: 25640 Summary: -Wpessimizing-move false positive for return value of statement expression Product: clang Version: 3.7 Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Frontend Assignee: unassignedclangb...@nondot.org Reporter: su...@fb.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified The following code generates a -Wpessimizing-move violation: ``` #include <memory> #include <utility> class C {}; void f() { auto c = ({auto c1 = std::make_unique<C>(); std::move(c1);}); } 1.cpp:5:47: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move] auto c = ({auto c1 = std::make_unique<C>(); std::move(c1);}); ^ 1.cpp:5:47: note: remove std::move call here auto c = ({auto c1 = std::make_unique<C>(); std::move(c1);}); ^~~~~~~~~~ ~ ``` When `std::move` is removed, it becomes a syntax error: ``` 1.cpp:5:47: error: call to deleted constructor of 'std::unique_ptr<C, std::default_delete<C> >' auto c = ({auto c1 = std::make_unique<C>(); c1;}); ^~ .../unique_ptr.h:356:7: note: 'unique_ptr' has been explicitly marked deleted here unique_ptr(const unique_ptr&) = delete; ^ 1 error generated. ``` clang --version clang version 3.8.0 (trunk 251726) Target: x86_64-unknown-linux-gnu Thread model: posix -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs