From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 728 invoked by alias); 13 Jun 2012 05:00:57 -0000 Received: (qmail 717 invoked by uid 22791); 13 Jun 2012 05:00:55 -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-qa0-f47.google.com (HELO mail-qa0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Jun 2012 05:00:29 +0000 Received: by qabg1 with SMTP id g1so3079102qab.20 for ; Tue, 12 Jun 2012 22:00:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.101.8 with SMTP id a8mr24633828qao.1.1339563629084; Tue, 12 Jun 2012 22:00:29 -0700 (PDT) Received: by 10.229.192.129 with HTTP; Tue, 12 Jun 2012 22:00:29 -0700 (PDT) In-Reply-To: <4EB36120.3060603@redhat.com> References: <4EB36120.3060603@redhat.com> Date: Wed, 13 Jun 2012 05:50: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 Content-Transfer-Encoding: quoted-printable 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-06/txt/msg00779.txt.bz2 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. =A0We have done that for reference variables, but not in > other cases, such as aggregate initialization of a struct with reference > members. =A0In C++11, elements of a std::initializer_list have the same > semantics; they live as long as the std::initializer_list. =A0Again, we w= ere > implementing that for initializer_list variables but not for > initializer_list subobjects. =A0This 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. =A0To 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 o= ne > EH region for cleaning up the whole array rather than one per element. = =A0To > 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 mangl= ed > 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=3D53650 --=20 H.J.