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

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

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

commit r14-9658-gde0886d48032332d10e4acb5d15c8789b281b6fe
Author: Marek Polacek <pola...@redhat.com>
Date:   Mon Mar 25 15:32:20 2024 -0400

    c++: broken direct-init with trailing array member [PR114439]

    can_init_array_with_p is wrongly saying that the init for 's' here:

      struct S {
        int *list = arr;
        int arr[];
      };

      struct A {
        A() {}
        S s[2]{};
      };

    is invalid.  But as process_init_constructor_array says, for "non-constant
    initialization of trailing elements with no explicit initializers" we use
    a VEC_INIT_EXPR wrapped in a TARGET_EXPR, built in
process_init_constructor.

    Unfortunately we didn't have a test for this scenario so I didn't
    realize can_init_array_with_p must handle it.

            PR c++/114439

    gcc/cp/ChangeLog:

            * init.cc (can_init_array_with_p): Return true for a VEC_INIT_EXPR
            wrapped in a TARGET_EXPR.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/array65.C: New test.

Reply via email to