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.
commit 3635dadac4d1e507b80f21f673530f322752df9b
Author: Jason Merrill <ja...@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 ();
+ }
+};