diff mbox

C++ PATCH for c++/60980 (value-initialization of array member)

Message ID 5361071D.2050904@redhat.com
State New
Headers show

Commit Message

Jason Merrill April 30, 2014, 2:22 p.m. UTC
My change to handle trivial but not callable constructors mistakenly 
removed the check that an object is of class type before we try to call 
its constructor.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.9.
diff mbox

Patch

commit 3635dadac4d1e507b80f21f673530f322752df9b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 29 17:08:16 2014 -0400

    	PR c++/60980
    	* init.c (build_value_init): Don't try to call an array constructor.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 8b9405c..46422a5 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -339,7 +339,8 @@  build_value_init (tree type, tsubst_flags_t complain)
   gcc_assert (!processing_template_decl
 	      || (SCALAR_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE));
 
-  if (type_build_ctor_call (type))
+  if (CLASS_TYPE_P (type)
+      && type_build_ctor_call (type))
     {
       tree ctor = build_aggr_init_expr
 	(type,
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted49.C b/gcc/testsuite/g++.dg/cpp0x/defaulted49.C
new file mode 100644
index 0000000..357be41
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted49.C
@@ -0,0 +1,15 @@ 
+// PR c++/60980
+// { dg-do compile { target c++11 } }
+
+struct x0
+{
+  x0 () = default;
+};
+struct x1
+{
+  x0 x2[2];
+  void x3 ()
+  {
+    x1 ();
+  }
+};