This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/986] g++ misses warning for & on temporary
- From: "joerg dot richter at pdv-fs dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jun 2004 08:31:26 -0000
- Subject: [Bug c++/986] g++ misses warning for & on temporary
- References: <20001205001601.986.wolfgang.bangerth@iwr.uni-heidelberg.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From joerg dot richter at pdv-fs dot de 2004-06-16 08:31 -------
The lifetime of the temporary is not expanded to Y's lifetime.
12.2/5
"A temporary bound to a reference member in a constructor's ctor-initializer
persists until the constructor exits."
So acually there is a dangling reference after the constructor was called.
I think a warning in this place would be fine.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=986