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

Reply via email to