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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

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

commit r10-6820-gb07c085581eb98cde408d9583ee17d58832826ae
Author: Marek Polacek <pola...@redhat.com>
Date:   Thu Feb 13 14:05:51 2020 -0500

    c++: Fix ICE with ill-formed array list-initialization [PR93712]

    My P0388R4 patch changed build_array_conv to create an identity
    conversion at the start of the conversion chain and now we crash
    in convert_like_real:

     7457     case ck_identity:
     7458       if (BRACE_ENCLOSED_INITIALIZER_P (expr))
     7459         {
     7460           int nelts = CONSTRUCTOR_NELTS (expr);
     7461           if (nelts == 0)
     7462             expr = build_value_init (totype, complain);
     7463           else if (nelts == 1)
     7464             expr = CONSTRUCTOR_ELT (expr, 0)->value;
     7465           else
     7466             gcc_unreachable ();  // HERE
     7467         }

    in a test like this

      int f (int const (&)[2])
      { return f({1, "M"}); }

    Instead of creating a ck_identity at the start of the conversion chain,
    so that conv_get_original_expr can be used with a ck_aggr, let's set
    u.expr for a ck_aggr, and adjust next_conversion not to try to see
    what's next in the chain if it gets a ck_aggr.

    2020-02-24  Marek Polacek  <pola...@redhat.com>

        PR c++/93712 - ICE with ill-formed array list-initialization.
        * call.c (next_conversion): Return NULL for ck_aggr.
        (build_aggr_conv): Set u.expr instead of u.next.
        (build_array_conv): Likewise.
        (build_complex_conv): Likewise.
        (conv_get_original_expr): Handle ck_aggr.

        * g++.dg/cpp0x/initlist-array11.C: New test.

Reply via email to