Consider: struct X { X(); explicit X(const X&); };
void f(X); void g(const X&); int main() { X x; f(x); f(X()); g(x); g(X()); } We currently give errors for f(x), f(X()) and g(X()), but not g(x). This is not quite the behavior of EDG which allows g(X()). There are (at least) two pertinent cwg defect reports: 152 and 391. 152 has TC1 status (it is normative) and clarifies the behavior for f(), and is consistent with the bevavior of both gcc and EDG. Issue 391 addresses g() and (I believe) explains the discrepancy between gcc and EDG by specifying that X() will bind directly to the reference parameter of g() with no copy. This issue has been voted on in full committee and approved as a dr. However the next available time to make anything normative is C++0X. So 391 has been applied to the working draft, and EDG has apparently implemented it. I respectfully request that gcc implement it as well. The issue is non-controversial on the committee and is causing problems with client code today. -- Summary: Reference binding and explicit copy constructors Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hhinnant at apple dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25950