https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94041

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:beaee0a871b6485d20573fe050b1fd425581e56a

commit r12-6328-gbeaee0a871b6485d20573fe050b1fd425581e56a
Author: Jason Merrill <ja...@redhat.com>
Date:   Sat Jan 1 16:00:22 2022 -0500

    c++: temporary lifetime with array aggr init [PR94041]

    The previous patch fixed temporary lifetime for aggregate initialization of
    classes; this one extends that fix to arrays.  This specifically reverses
my
    r74790, the patch for PR12253, which was made wrong when these semantics
    were specified in DR201.

    Since the array cleanup region encloses the regions for any temporaries, we
    don't need to add an additional region for the array object itself in
either
    initialize_local_var or split_nonconstant_init; we do, however, need to
tell
    split_nonconstant_init how to disable the cleanup once an enclosing object
    is fully constructed, at which point we want to run that destructor
instead.

            PR c++/94041

    gcc/cp/ChangeLog:

            * decl.c (initialize_local_var): Fix comment.
            * init.c (build_new_1): Do stabilize array init.
            (build_vec_init): Use TARGET_EXPR for cleanup.  Initialization
            of an element from an explicit initializer is not a
            full-expression.
            * tree.c (expand_vec_init_expr): Pass flags through.
            * typeck2.c (split_nonconstant_init_1): Handle VEC_INIT_EXPR.
            (split_nonconstant_init): Handle array cleanups.
            * cp-tree.h: Adjust.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/array12.C:
            * g++.dg/init/aggr7-eh2.C: New test.
            * g++.dg/init/aggr7-eh3.C: New test.

Reply via email to