This code emits error C2248: 'A::A' : cannot access private member declared in class 'A'
in VS2010, although RVO doesn't need a copy constructor. To prove this, just turn public the declaration A(const A&);
below, and the code will execute without a problem, even without a definition for the copy constructor .
class A
{
int i;
A(const A&);
public:
A() : i(1) {}
};
A f() { return A(); }
int main()
{
A a;
a = f();
}