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: "raf2 at msux dot cjb dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 May 2007 16:18:41 -0000
- Subject: [Bug c++/986] g++ misses warning for & on temporary
- References: <bug-986-184@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #14 from raf2 at msux dot cjb dot net 2007-05-08 17:18 -------
I first was hit by an error using MinGW... when I compiled and executed the
first attached file, it wrote:
John drives a: "bus"
Otto drives a: "bus"
Which was wrong, I reported the bug and a guy from MinGW kindly explained that
if it worked then that would be purely by accident and added:
" When you declare the argument without '&' then it will make a temporary copy
of the Automobile object on the stack, but it is wrong to store a reference to
a temporary object because it will be invalid after the constructor returns.".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=986