public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36430] New: Cannot convert a temporary to a non-const reference even with conversion operator
@ 2008-06-03 18:39 gbrammer at gmx dot de
2008-08-21 11:44 ` [Bug c++/36430] " gcc-bugzilla at contacts dot eelis dot net
2008-08-21 12:05 ` paolo dot carlini at oracle dot com
0 siblings, 2 replies; 3+ messages in thread
From: gbrammer at gmx dot de @ 2008-06-03 18:39 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 870 bytes --]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/36430] Cannot convert a temporary to a non-const reference even with conversion operator
2008-06-03 18:39 [Bug c++/36430] New: Cannot convert a temporary to a non-const reference even with conversion operator gbrammer at gmx dot de
@ 2008-08-21 11:44 ` gcc-bugzilla at contacts dot eelis dot net
2008-08-21 12:05 ` paolo dot carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: gcc-bugzilla at contacts dot eelis dot net @ 2008-08-21 11:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from gcc-bugzilla at contacts dot eelis dot net 2008-08-21 11:43 -------
This report is invalid. By 12.3.2,
"A conversion function is never used to convert a
(possibly cv-qualified) object to the (possibly
cv-qualified) same object type (or a reference to it)."
Comeau warns explicitly about this, saying:
line 2: warning: "Foo::operator Foo &()" will not be
called for implicit or explicit conversions
--
gcc-bugzilla at contacts dot eelis dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc-bugzilla at contacts dot
| |eelis dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36430
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/36430] Cannot convert a temporary to a non-const reference even with conversion operator
2008-06-03 18:39 [Bug c++/36430] New: Cannot convert a temporary to a non-const reference even with conversion operator gbrammer at gmx dot de
2008-08-21 11:44 ` [Bug c++/36430] " gcc-bugzilla at contacts dot eelis dot net
@ 2008-08-21 12:05 ` paolo dot carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-08-21 12:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from paolo dot carlini at oracle dot com 2008-08-21 12:04 -------
*** This bug has been marked as a duplicate of 26698 ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36430
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-21 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-03 18:39 [Bug c++/36430] New: Cannot convert a temporary to a non-const reference even with conversion operator gbrammer at gmx dot de
2008-08-21 11:44 ` [Bug c++/36430] " gcc-bugzilla at contacts dot eelis dot net
2008-08-21 12:05 ` paolo dot carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).