public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH for c++/48370 (extending lifetime of temps in aggregate initialization)
Date: Wed, 13 Jun 2012 05:50:00 -0000	[thread overview]
Message-ID: <CAMe9rOqav_q8J+4FbmE0FnwrwJLv7BS9UMCMYq-Z118br4ihWw@mail.gmail.com> (raw)
In-Reply-To: <4EB36120.3060603@redhat.com>

On Thu, Nov 3, 2011 at 8:50 PM, Jason Merrill <jason@redhat.com> 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

-- 
H.J.

  parent reply	other threads:[~2012-06-13  5:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-04  5:55 Jason Merrill
2011-11-05  4:42 ` Jason Merrill
2011-11-07 18:08   ` Jason Merrill
2012-06-13  5:50 ` H.J. Lu [this message]
2012-08-07 19:56   ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMe9rOqav_q8J+4FbmE0FnwrwJLv7BS9UMCMYq-Z118br4ihWw@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).