From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25585 invoked by alias); 7 Aug 2012 19:56:54 -0000 Received: (qmail 25576 invoked by uid 22791); 7 Aug 2012 19:56:53 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-vb0-f47.google.com (HELO mail-vb0-f47.google.com) (209.85.212.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Aug 2012 19:56:40 +0000 Received: by vbbfr13 with SMTP id fr13so3616117vbb.20 for ; Tue, 07 Aug 2012 12:56:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.154.148 with SMTP id o20mr12003225vcw.18.1344369399810; Tue, 07 Aug 2012 12:56:39 -0700 (PDT) Received: by 10.58.165.104 with HTTP; Tue, 7 Aug 2012 12:56:39 -0700 (PDT) In-Reply-To: References: <4EB36120.3060603@redhat.com> Date: Tue, 07 Aug 2012 19:56:00 -0000 Message-ID: Subject: Re: C++ PATCH for c++/48370 (extending lifetime of temps in aggregate initialization) From: "H.J. Lu" To: Jason Merrill Cc: gcc-patches List Content-Type: text/plain; charset=ISO-8859-1 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-08/txt/msg00381.txt.bz2 On Tue, Jun 12, 2012 at 10:00 PM, H.J. Lu wrote: > On Thu, Nov 3, 2011 at 8:50 PM, Jason Merrill wrote: >> 12.2 states that a temporary bound to a reference lives as long as the >> reference itself. We have done that for reference variables, but not in >> other cases, such as aggregate initialization of a struct with reference >> members. In C++11, elements of a std::initializer_list have the same >> semantics; they live as long as the std::initializer_list. Again, we were >> implementing that for initializer_list variables but not for >> initializer_list subobjects. This patch fixes that. >> >> Furthermore, if a temporary's lifetime is extended, we need to also extend >> the lifetimes of any temporaries bound to references in its initializer, and >> so on. >> >> The patch introduces a function extend_ref_init_temps called from >> store_init_value after the call to digest_init. To expose elements of an >> initializer_list to this function, I needed to stop using >> build_aggr_init_full_exprs for aggregate initialization of arrays, and >> consequently needed to call build_vec_init from store_init_value to use one >> EH region for cleaning up the whole array rather than one per element. To >> deal with multiple extended temporaries, we need to change the cleanup >> pointer from a single tree to a VEC, and add a discriminator to the mangled >> name of reference init temporaries; this has no ABI impact, since the >> temporaries have no linkage, but I also updated the demangler accordingly. >> >> Since we now do lifetime extension in extend_ref_init_temps, we can >> drastically simplify initialize_reference and do away with >> build_init_list_var_init. >> >> Tested x86_64-pc-linux-gnu, applying to trunk. > > This caused: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53650 > This also caused: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54197 -- H.J.