From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8687 invoked by alias); 7 Nov 2011 17:47:32 -0000 Received: (qmail 8676 invoked by uid 22791); 7 Nov 2011 17:47:31 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Nov 2011 17:47:16 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA7HlGPC022366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Nov 2011 12:47:16 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pA7HlF0j027539 for ; Mon, 7 Nov 2011 12:47:16 -0500 Received: from [0.0.0.0] (ovpn-113-127.phx2.redhat.com [10.3.113.127]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pA7HlEqt001167 for ; Mon, 7 Nov 2011 12:47:15 -0500 Message-ID: <4EB819A2.9070304@redhat.com> Date: Mon, 07 Nov 2011 18:08:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111001 Thunderbird/7.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: Re: C++ PATCH for c++/48370 (extending lifetime of temps in aggregate initialization) References: <4EB36120.3060603@redhat.com> <4EB4AC1D.9040303@redhat.com> In-Reply-To: <4EB4AC1D.9040303@redhat.com> Content-Type: multipart/mixed; boundary="------------090708000802050201040504" 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: 2011-11/txt/msg01022.txt.bz2 This is a multi-part message in MIME format. --------------090708000802050201040504 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 504 On 11/04/2011 11:23 PM, Jason Merrill wrote: > While working on a followup, I noticed that this patch runs temporary > cleanups in the wrong order. Fixed (and tested) thus. This patch broke bootstrap because it allocated a gc-able vector and held it across the definition of a function, at the end of which it was collected, but we still tried to use it. Fixed by allocating it only in the cases where we might do something with it (i.e. variables). Tested x86_64-pc-linux-gnu, applying to trunk. --------------090708000802050201040504 Content-Type: text/x-patch; name="48370-3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="48370-3.patch" Content-length: 1663 commit 1cd13481ae03948febfc551ff1a4959e33892eef Author: Jason Merrill Date: Sat Nov 5 17:11:34 2011 -0400 * decl.c (cp_finish_decl): Only make_tree_vector if we're calling check_initializer. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d2daf91..3b283d8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6049,9 +6049,12 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, /* This variable seems to be a non-dependent constant, so process its initializer. If check_initializer returns non-null the initialization wasn't constant after all. */ - tree init_code = check_initializer (decl, init, flags, &cleanups); + tree init_code; + cleanups = make_tree_vector (); + init_code = check_initializer (decl, init, flags, &cleanups); if (init_code == NULL_TREE) init = NULL_TREE; + release_tree_vector (cleanups); } else if (!DECL_PRETTY_FUNCTION_P (decl)) /* Deduce array size even if the initializer is dependent. */ @@ -6150,6 +6153,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, error ("Java object %qD not allocated with %", decl); init = NULL_TREE; } + cleanups = make_tree_vector (); init = check_initializer (decl, init, flags, &cleanups); /* Thread-local storage cannot be dynamically initialized. */ if (DECL_THREAD_LOCAL_P (decl) && init) @@ -6320,6 +6324,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, unsigned i; tree t; FOR_EACH_VEC_ELT (tree, cleanups, i, t) push_cleanup (decl, t, false); + release_tree_vector (cleanups); } if (was_readonly) --------------090708000802050201040504--