From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26588 invoked by alias); 2 Jul 2014 12:19:19 -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 26549 invoked by uid 89); 2 Jul 2014 12:19:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f44.google.com Received: from mail-pa0-f44.google.com (HELO mail-pa0-f44.google.com) (209.85.220.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 02 Jul 2014 12:19:12 +0000 Received: by mail-pa0-f44.google.com with SMTP id rd3so12468124pab.31 for ; Wed, 02 Jul 2014 05:19:10 -0700 (PDT) X-Received: by 10.66.179.111 with SMTP id df15mr3681690pac.52.1404303550341; Wed, 02 Jul 2014 05:19:10 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-155-134.oycza5.sa.bigpond.net.au. [58.160.155.134]) by mx.google.com with ESMTPSA id js3sm37066037pbb.50.2014.07.02.05.19.08 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Jul 2014 05:19:09 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 92635EA3956; Wed, 2 Jul 2014 21:49:04 +0930 (CST) Date: Wed, 02 Jul 2014 12:19:00 -0000 From: Alan Modra To: Marc Glisse Cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: Warn when returning the address of a temporary (middle-end) v2 Message-ID: <20140702121904.GI4471@bubble.grove.modra.org> Mail-Followup-To: Marc Glisse , Jeff Law , gcc-patches@gcc.gnu.org References: <53B1D0C5.30901@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00116.txt.bz2 On Mon, Jun 30, 2014 at 11:37:50PM +0200, Marc Glisse wrote: > On Mon, 30 Jun 2014, Jeff Law wrote: > > >On 06/29/14 03:22, Marc Glisse wrote: > >> > >>After looking at PR 61597, I updated the 2 conditions to: > >> > >>+ if ((TREE_CODE (valbase) == VAR_DECL > >>+ && !is_global_var (valbase)) > >>+ || TREE_CODE (valbase) == PARM_DECL) > >> > >>a PARM_DECL is a local variable and returning its address is wrong, > >>isn't it? > >Right. It can live in either a caller or callee allocated slot. > > The "caller" case scares me a bit. Is it really wrong to return the > address in that case? The slot still exists after returning if the > caller is responsible for it. At least on powerpc64, which uses a caller allocated parameter save area, returning the address of something in the parameter save area merits a warning. The ABIs explicitly state that the parameter save area is not preserved over function calls. Also note that anything left in a caller allocated parameter save area will potentially be trashed by arguments written for the next call. -- Alan Modra Australia Development Lab, IBM