<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - -Wpessimizing-move false positive for return value of statement expression"
   href="https://llvm.org/bugs/show_bug.cgi?id=25640">25640</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wpessimizing-move false positive for return value of statement expression
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sugak@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>