struct Foo { operator Foo & () { return *this; } }; void frobnicate(Foo &) { /* in reality, the Foo is changed here and returned */ } int main () { frobnicate (Foo()); }
temporary.cpp:8: error: invalid initialization of non-const reference of type Foo& from a temporary of type Foo temporary.cpp:4: error: in passing argument 1 of void frobnicate(Foo&) This works with g++ 4.1, but does not work with 4.2 and 4.3. -- Summary: Cannot convert a temporary to a non-const reference even with conversion operator Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gbrammer at gmx dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36430