From patchwork Thu Dec 6 22:15:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for c++/55249 (missing symbol with array and multiple copy constructors) Date: Thu, 06 Dec 2012 12:15:29 -0000 From: Jason Merrill X-Patchwork-Id: 204329 Message-Id: <50C11901.1020407@redhat.com> To: gcc-patches List When we're modeling what the initialization of one array element will look like, it would help to use the type of the array element. Tested x86_64-pc-linux-gnu, applying to 4.6, 4.7 and trunk. commit 0d89242428ea0917960bc6b1704605d9bc67bbb0 Author: Jason Merrill Date: Thu Dec 6 15:48:56 2012 -0500 PR c++/55249 * tree.c (build_vec_init_elt): Use the type of the initializer. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 58725f3..28ff0f2 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -524,7 +524,8 @@ build_vec_init_elt (tree type, tree init, tsubst_flags_t complain) argvec = make_tree_vector (); if (init) { - tree dummy = build_dummy_object (inner_type); + tree init_type = strip_array_types (TREE_TYPE (init)); + tree dummy = build_dummy_object (init_type); if (!real_lvalue_p (init)) dummy = move (dummy); argvec->quick_push (dummy); diff --git a/gcc/testsuite/g++.dg/template/array25.C b/gcc/testsuite/g++.dg/template/array25.C new file mode 100644 index 0000000..4f3ccbf --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array25.C @@ -0,0 +1,18 @@ +// PR c++/55249 + +template struct A +{ + _Tp _M_instance[1]; +}; +template struct inner_type +{ + inner_type () {} + inner_type (inner_type &); + inner_type (const inner_type &) {} +}; + +int +main () +{ + A > a, b = a; +}