<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 --- - self move assignment broken for std::string and std::vector"
   href="https://llvm.org/bugs/show_bug.cgi?id=24453">24453</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>self move assignment broken for std::string and std::vector
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sherm1@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Self-move assignment should be a no-op like self-copy assignment, but
std::string and std::vector seem to clear the object on self move assign. For
example, the code below outputs an empty string on OSX clang 3.6. On Ubuntu
14.04 both clang and gcc leave the string unchanged; Visual Studio 2015 also
leaves it unchanged.

Self move for std::vector cleared the vector in gcc and clang everywhere but
not in VS2015.

#include <string>
#include <iostream>
#include <utility>
using std::cout; using std::endl;

int main() {
    std::string s2("goodbye");
    cout << "s2=" << s2 << endl;

    s2 = s2;
    cout << "s2=s2 -> s2=" << s2 << endl;
    s2 = std::move(s2);
    cout << "s2=move(s2) -> s2=" << s2 << endl; // should say "goodbye"
}</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>