Call to constructor not recognized as lvalue in function call

David Judson djudson@houston.westerngeco.slb.com
Fri Jul 12 09:02:00 GMT 2002


The following fails to compile with g++ (2.96, 3.0.4 , 3.1)

class T{}
{
public:
     T(){}
     ~T(){}
};

void fxn(T&);

void x()
{
    fxn(T());  // error : cannot convert T() to T&
}

However, in another context, T() is recognized as an lvalue.

void y()
{
    T aT;
     T() = aT;
}

Since this code all compiles with Solaris (Forte), Intel and Microsoft C++ 
compilers, I'm assume that it's legal C++.



More information about the Gcc-bugs mailing list