public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26191] New: temporary is not bound to non-const reference
@ 2006-02-09 10:02 istvan dot benedek dot ext at deutsche-boerse dot com
2006-02-15 19:45 ` [Bug c++/26191] " bangerth at dealii dot org
0 siblings, 1 reply; 2+ messages in thread
From: istvan dot benedek dot ext at deutsche-boerse dot com @ 2006-02-09 10:02 UTC (permalink / raw)
To: gcc-bugs
I expect the following snippet to compile without errors (even a warning(s)
should be parametrized).
As stated in [class.temporary]/5, the temporaries can be bound to non-const
references too...
struct A {};
A fct() { return A(); }
int main(int, char**)
{
const A& aConstRef = fct(); // compiles: temporary bound to const reference
A& aRef = fct(); // error: temporary bound to non-const reference
return 0;
}
I called g++ wo. parameters [sparc-sun-solaris2.8].
Ben
--
Summary: temporary is not bound to non-const reference
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: istvan dot benedek dot ext at deutsche-boerse dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26191
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/26191] temporary is not bound to non-const reference
2006-02-09 10:02 [Bug c++/26191] New: temporary is not bound to non-const reference istvan dot benedek dot ext at deutsche-boerse dot com
@ 2006-02-15 19:45 ` bangerth at dealii dot org
0 siblings, 0 replies; 2+ messages in thread
From: bangerth at dealii dot org @ 2006-02-15 19:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from bangerth at dealii dot org 2006-02-15 19:45 -------
The clause you cite only deals with the lifetime of temporaries, not with
the question whether they can be bound to references in the first place.
8.5.3/5 states that references can only be bound to lvalues or, if they
are rvalues only to constant references.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26191
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-15 19:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-09 10:02 [Bug c++/26191] New: temporary is not bound to non-const reference istvan dot benedek dot ext at deutsche-boerse dot com
2006-02-15 19:45 ` [Bug c++/26191] " bangerth at dealii dot org
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).