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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Marek Polacek
<mpola...@gcc.gnu.org>:

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

commit r14-11167-gdf3ae94a5eb3090e59d5fd8d3ccc3d8231bac87f
Author: Marek Polacek <pola...@redhat.com>
Date:   Thu Sep 5 16:45:32 2024 -0400

    c++: ICE with structured bindings and m-d array [PR102594]

    We ICE in decay_conversion with this test:

      struct S {
        S() {}
      };
      S arr[1][1];
      auto [m](arr3);

    But not when the last line is:

      auto [n] = arr3;

    Therefore the difference is between copy- and direct-init.  In
    particular, in build_vec_init we have:

      if (direct_init)
        from = build_tree_list (NULL_TREE, from);

    and then we call build_vec_init again with init==from.  Then
    decay_conversion gets the TREE_LIST and it crashes.

    build_aggr_init has:

                  /* Wrap the initializer in a CONSTRUCTOR so that
build_vec_init
                     recognizes it as direct-initialization.  */
                  init = build_constructor_single (init_list_type_node,
                                                   NULL_TREE, init);
                  CONSTRUCTOR_IS_DIRECT_INIT (init) = true;

    so I propose to do the same in build_vec_init.

            PR c++/102594

    gcc/cp/ChangeLog:

            * init.cc (build_vec_init): Build up a CONSTRUCTOR to signal
            direct-initialization rather than a TREE_LIST.

    gcc/testsuite/ChangeLog:

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

    Reviewed-by: Jason Merrill <ja...@redhat.com>
    (cherry picked from commit 96e0370f4daef29b918aafcff68c7f5e4ef397fd)
  • [Bug c++/102594] ICE in decay_c... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to