Patchwork C++ PATCH for c++/55249 (missing symbol with array and multiple copy constructors)

login
register
mail settings
Submitter Jason Merrill
Date Dec. 6, 2012, 10:15 p.m.
Message ID <50C11901.1020407@redhat.com>
Download mbox | patch
Permalink /patch/204329/
State New
Headers show

Comments

Jason Merrill - Dec. 6, 2012, 10:15 p.m.
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.

Patch

commit 0d89242428ea0917960bc6b1704605d9bc67bbb0
Author: Jason Merrill <jason@redhat.com>
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 <typename _Tp> struct A
+{
+  _Tp _M_instance[1];
+};
+template <class> struct inner_type
+{
+    inner_type () {}
+    inner_type (inner_type &);
+    inner_type (const inner_type &) {}
+};
+
+int
+main ()
+{
+    A <inner_type <int> > a, b = a;
+}