class A
{
...
}
A foo()
{
A fooA;
return fooA;
}
int main()
{
A &a = foo();
return 0;
}
Here is the simple code. I test this in VS2013. there are no error or warning. I think foo() function return temporary of "fooA". That is rvalue. In g++, error occur in "A &a = foo();". In error message, it must be "const A &a". I think g++ is right. And I don't know why VS2013 could compile it?