[llvm-bugs] [Bug 24453] New: self move assignment broken for std::string and std::vector

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 13 16:03:20 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24453

            Bug ID: 24453
           Summary: self move assignment broken for std::string and
                    std::vector
           Product: libc++
           Version: 3.6
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sherm1 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

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"
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150813/e9209baf/attachment.html>


More information about the llvm-bugs mailing list