@@ -343,10 +343,6 @@ build_value_init (tree type, tsubst_flags_t complain)
A program that calls for default-initialization or
value-initialization of an entity of reference type is ill-formed. */
- /* The AGGR_INIT_EXPR tweaking below breaks in templates. */
- gcc_assert (!processing_template_decl
- || (SCALAR_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE));
-
if (CLASS_TYPE_P (type) && type_build_ctor_call (type))
{
tree ctor
@@ -354,6 +350,9 @@ build_value_init (tree type, tsubst_flags_t complain)
NULL, type, LOOKUP_NORMAL, complain);
if (ctor == error_mark_node || TREE_CONSTANT (ctor))
return ctor;
+ if (processing_template_decl)
+ /* The AGGR_INIT_EXPR tweaking below breaks in templates. */
+ return build_min (CAST_EXPR, type, NULL_TREE);
tree fn = NULL_TREE;
if (TREE_CODE (ctor) == CALL_EXPR)
fn = get_callee_fndecl (ctor);
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/105589
+// { dg-do compile { target c++11 } }
+
+struct X { X(); };
+
+struct array { X m[2]; };
+
+template<class>
+void f() {
+ array w = array{};
+}