diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 3ab7f96335c9ae5596a07a603b1637163e8e47f3..613775c5a7c821c9ddd08c507a248264d803e1fa 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4786,7 +4786,8 @@ build_vec_init (tree base, tree maxindex, tree init, tree field, elt; /* If the constructor already has the array type, it's been through digest_init, so we shouldn't try to do anything more. */ - bool digested = same_type_p (atype, TREE_TYPE (init)); + bool digested = (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE + && same_type_p (type, TREE_TYPE (TREE_TYPE (init)))); from_array = 0; if (length_check) diff --git a/gcc/testsuite/g++.dg/init/no-elide4.C b/gcc/testsuite/g++.dg/init/no-elide4.C new file mode 100644 index 0000000000000000000000000000000000000000..9377d9f01611961b959b70999f58e1cd7ffcf7d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/no-elide4.C @@ -0,0 +1,11 @@ +// PR c++/114619 +// { dg-do "compile" { target c++11 } } +// { dg-options "-fno-elide-constructors" } + +struct X { + X(const X&) {} +}; +extern X x; +void foo () { + new X[1]{x}; +}