From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18774 invoked by alias); 2 Dec 2012 12:32:23 -0000 Received: (qmail 18763 invoked by uid 22791); 2 Dec 2012 12:32:23 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,RDNS_NONE X-Spam-Check-By: sourceware.org Received: from Unknown (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sun, 02 Dec 2012 12:31:51 +0000 Received: (qmail invoked by alias); 02 Dec 2012 12:31:43 -0000 Received: from pD9FDE7B1.dip.t-dialin.net (EHLO [192.168.2.21]) [217.253.231.177] by mail.gmx.net (mp039) with SMTP; 02 Dec 2012 13:31:43 +0100 Message-ID: <50BB4A2D.5050408@gmx.net> Date: Sun, 02 Dec 2012 12:32:00 -0000 From: Olivier Ballereau User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Xinliang David Li CC: GCC Patches , Jason Merrill , Richard Guenther Subject: Re: New option to turn off stack reuse for temporaries References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00072.txt.bz2 Hello David, Sorry to come so late into the discussion, but... On 21/06/12 00:50, Xinliang David Li wrote: > One of the most common runtime errors we have seen in gcc-4_7 is > caused by dangling references to temporaries whole life time have > ended > > e.g, > > const A& a = foo(); > > or > foo (A());// where temp's address is saved and used after foo. > > Of course this is user error according to the standard, > [...] ... is the first of your 2 examples really a user error? If so, it breaks GotW #88: A Candidate For the “Most Important const” [1]. Can you please clarify? Thanks in advance! Olivier [1] http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/