From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27177 invoked by alias); 29 Jul 2014 19:13:26 -0000 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 Received: (qmail 27157 invoked by uid 89); 29 Jul 2014 19:13:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 29 Jul 2014 19:13:24 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6TJDMW2003653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Jul 2014 15:13:23 -0400 Received: from redhat.com (ovpn-116-45.ams2.redhat.com [10.36.116.45]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6TJDJKI030951 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Tue, 29 Jul 2014 15:13:21 -0400 Date: Tue, 29 Jul 2014 19:22:00 -0000 From: Marek Polacek To: David Malcolm Cc: Marc Glisse , Richard Sandiford , gcc-patches@gcc.gnu.org Subject: Re: Warn when returning the address of a temporary (middle-end) v2 Message-ID: <20140729191318.GZ30336@redhat.com> References: <87fvhmllc5.fsf@talisman.default> <1406660283.2134.122.camel@surprise> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1406660283.2134.122.camel@surprise> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2014-07/txt/msg02004.txt.bz2 On Tue, Jul 29, 2014 at 02:58:03PM -0400, David Malcolm wrote: > This is possibly a dumb question, but what happens for a static local, > rather than an auto local? e.g. > > int *f (void) > { > static int i; > return &i; > } This is fine. The variable i has a static storage duration, so is allocated when the program begins and is deallocated when the program ends. There's only one instance of the variable i. Marek