I encountered a problem where gcc compiler moved local variable (not temporary) as rvalue argument to a function. I have a simple example:
class A
{
public:
    A() {}
    A& operator=(const A&) { std::cout << "const A&\n"; return *this; }
    A& operator=(A&&) { std::cout << "A&&\n"; return *this; }
};
class B
{
public:
    B() {}
    B& operator=(const B&) { std::cout << "const B&\n"; return *this; }
    B& operator=(B&&) { std::cout << "B&&\n"; return *this; }
    template<class T> B& operator=(const T&) { std::cout << "const T& (T is " << typeid(T).name() << ")\n"; return *this; }
    template<class T> B& operator=(T&&) { std::cout << "T&& (T is " << typeid(T).name() << ")\n"; return *this; }
};
int main(int argc, char **argv)
{
    A a1;
    A a2;
    a1 = a2;
    B b1;
    B b2;
    std::cout << "B is " << typeid(B).name() << "\n";
    b1 = b2;
}
The output:
const A&
B is 1B
T&& (T is 1B)
I did not expect it because move assignment zeros the rvalue. In my case it caused to crash because b2 was used in after b1=b2;
The question is why it happened.
 
    