Is it permitted for an object (in particular of an std
class) to be self-moved or it is an undefined-behavior?
Consider an example:
#include <iostream>
#include <string>
int main()
{
std::string s("123");
s = std::move(s);
std::cout << s;
}
In gcc/clang the program prints nothing, so s
string is lost during moving:
https://gcc.godbolt.org/z/xqTWKfMxM
But in MSVC it works fine.