split_nonconstant_init_1 was confused by a CONSTRUCTOR with non-aggregate
type, which (with COMPOUND_LITERAL_P set) we use in a template to represent
a braced functional cast. It seems to me that there's no good reason to do
split_nonconstant_init at all in a template.
gcc/cp/ChangeLog:
PR c++/97899
* typeck2.c (store_init_value): Don't split_nonconstant_init in a
template.
gcc/testsuite/ChangeLog:
PR c++/97899
* g++.dg/cpp0x/initlist-template3.C: New test.
the bits that are constant, and then return an expression that
will perform the dynamic initialization. */
if (value != error_mark_node
+ && !processing_template_decl
&& (TREE_SIDE_EFFECTS (value)
|| vla_type_p (type)
|| ! reduced_constant_expression_p (value)))
--- /dev/null
+// PR c++/97899
+// { dg-do compile { target c++11 } }
+
+template <typename T = int>
+int fn()
+{
+ return 1;
+}
+
+template <typename T>
+void bar() {
+ const int i = int{fn()};
+}