From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7260 invoked by alias); 27 Sep 2002 22:52:30 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 7253 invoked from network); 27 Sep 2002 22:52:29 -0000 Received: from unknown (HELO smtp.web.de) (217.72.192.151) by sources.redhat.com with SMTP; 27 Sep 2002 22:52:29 -0000 Received: from [129.187.26.122] (helo=mephisto) by smtp.web.de with asmtp (WEB.DE(Exim) 4.75 #2) id 17v3yG-0008Tr-00 for gcc-help@gcc.gnu.org; Sat, 28 Sep 2002 00:52:29 +0200 Content-Type: text/plain; charset="iso-8859-1" From: Sebastian Huber To: gcc-help@gcc.gnu.org Subject: Re: GCC compile problem ... Date: Fri, 27 Sep 2002 15:52:00 -0000 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200209280052.38305.sebastian-huber@web.de> X-SW-Source: 2002-09/txt/msg00223.txt.bz2 Hello John, On Friday 27 September 2002 09:31, John Love-Jensen wrote: > 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 t= he > string reference to the temporary. > > The cout << s << "\n"; is operating on the s string that has been > destructed, which is very dangerous. I think, that this is not true. If you assign a temporary object to a const= ant=20 reference, the object will survive until the reference is destroyed. > 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 Bye