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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <[email protected]>:

https://gcc.gnu.org/g:2581e76a4a00023f81353b01ff9f7f3967205cf7

commit r16-8012-g2581e76a4a00023f81353b01ff9f7f3967205cf7
Author: Marek Polacek <[email protected]>
Date:   Mon Mar 9 11:40:54 2026 -0400

    c++: ICE with structured bindings and arrays [PR120285]

    In r15-3933 I started using a CONSTRUCTOR to signal direct-init
    to build_vec_init rather than a TREE_LIST.  That broke

      struct S {
        int a = 1;
      };
      void foo() {
        S arr[2];
        auto [x, y](arr);
      }

    because we pass that new CONSTRUCTOR not to build_vec_init but to
    build_aggr_init which then crashes in digest_init_r because the
    new CONSTRUCTOR wasn't reshaped.  It should work to reshape it if
    its type is CP_AGGREGATE_TYPE_P but it might be safer to resort
    back to building up a list if we're not going to go to build_vec_init.

            PR c++/120285

    gcc/cp/ChangeLog:

            * init.cc (build_vec_init): Only build up a CONSTRUCTOR for
            arrays, otherwise use a TREE_LIST like prior to r15-3933.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/decomp68.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to