[Bug c++/124456] ICE: tree check: expected tree_vec, have array_ref in tsubst_pack_expansion, at cp/pt.cc:14138

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Mar 14 08:54:05 GMT 2026


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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:4f9e2843084b7934a27337ae57bd3313723a5c9b

commit r16-8091-g4f9e2843084b7934a27337ae57bd3313723a5c9b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 14 09:52:42 2026 +0100

    c++: Fix up partial instantiation of structured binding packs [PR124456]

    The following testcase ICEs during partial instantiation of structured
    binding pack.  tsubst_pack_expansion assumed DECL_VALUE_EXPR
    in that case will be TREE_VEC containing what should be expanded.
    But when the initializer of the structured bindings is still type
dependent,
    we know neither the size of the sb pack nor its content, cp_finish_decomp
    in that case doesn't set DECL_VALUE_EXPR to a TREE_VEC at all, but to
    ARRAY_REF of the base and index within the structured binding (and pack if
    any).
    tsubst_pack_expansion can set arg_pack to NULL_TREE and in that case
          else
            {
              /* We can't substitute for this parameter pack.  We use a flag as
                 well as the missing_level counter because function parameter
                 packs don't have a level.  */
              gcc_assert (processing_template_decl || is_auto (parm_pack)
                          || args == NULL_TREE);
              unsubstituted_packs = true;
            }
    will trigger and later on in the function unsubstituted_packs is handled
    properly.

    So, the following patch makes sure to set arg_pack to NULL_TREE in that
    case.

    2026-03-14  Jakub Jelinek  <jakub@redhat.com>

            PR c++/124456
            * pt.cc (tsubst_pack_expansion): For structured binding pack
            with type dependent pack set arg_pack to NULL_TREE.

            * g++.dg/cpp26/decomp27.C: New test.


More information about the Gcc-bugs mailing list