[Bug c++/986] g++ misses warning for & on temporary
raf2 at msux dot cjb dot net
gcc-bugzilla@gcc.gnu.org
Tue May 8 16:18:00 GMT 2007
------- 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
More information about the Gcc-bugs
mailing list