This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC compile problem ...
- From: John Love-Jensen <eljay at adobe dot com>
- To: <gcc at wiesinger dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Fri, 27 Sep 2002 11:31:56 -0500
- Subject: Re: GCC compile problem ...
Hi Gerhard,
The TEMPORARY from test.getString is being set to a REFERENCE.
The TEMPORARY is destructed, more-or-less, after the semicolon that set the
string reference to the temporary.
The cout << s << "\n"; is operating on the s string that has been
destructed, which is very dangerous. Who knows what state that freed STACK
memory and HEAP memory will be in, especially during the machinations of the
ostream processing.
Borland C++ 5.5 and Microsoft Visual C++ 6.0 should be ashamed. Shame.
Shame.
--Eljay