This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/69730] problem with references and templates when using O2
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 09 Feb 2016 10:50:47 +0000
- Subject: [Bug c++/69730] problem with references and templates when using O2
- Auto-submitted: auto-generated
- References: <bug-69730-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69730
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I suspect it's because x() returns an rvalue B (a copy) which you then instruct
to
return a reference to its member which you bind to x. But that copy of B dies
after
const double & x = a.x().value();
and thus the content of what x refers to is gone.