This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36430] New: Cannot convert a temporary to a non-const reference even with conversion operator
- From: "gbrammer at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jun 2008 18:38:41 -0000
- Subject: [Bug c++/36430] New: Cannot convert a temporary to a non-const reference even with conversion operator
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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