commit 1738cacbeb65b9fb0e155fa7a1369e647674082c
Author: Jason Merrill <jason@redhat.com>
Date: Fri Aug 19 00:52:38 2011 -0400
PR c++/50024
* semantics.c (maybe_constant_value): Don't try to fold { }.
* pt.c (build_non_dependent_expr): Don't wrap { }.
* init.c (build_value_init): Allow scalar value-init in templates.
@@ -330,7 +330,7 @@ build_value_init (tree type, tsubst_flags_t complain)
constructor. */
/* The AGGR_INIT_EXPR tweaking below breaks in templates. */
- gcc_assert (!processing_template_decl);
+ gcc_assert (!processing_template_decl || SCALAR_TYPE_P (type));
if (CLASS_TYPE_P (type))
{
@@ -19669,6 +19669,10 @@ build_non_dependent_expr (tree expr)
if (TREE_CODE (expr) == THROW_EXPR)
return expr;
+ /* Don't wrap an initializer list, we need to be able to look inside. */
+ if (BRACE_ENCLOSED_INITIALIZER_P (expr))
+ return expr;
+
if (TREE_CODE (expr) == COND_EXPR)
return build3 (COND_EXPR,
TREE_TYPE (expr),
@@ -7542,6 +7542,7 @@ maybe_constant_value (tree t)
if (type_dependent_expression_p (t)
|| type_unknown_p (t)
+ || BRACE_ENCLOSED_INITIALIZER_P (t)
|| !potential_constant_expression (t)
|| value_dependent_expression_p (t))
{
new file mode 100644
@@ -0,0 +1,15 @@
+// PR c++/50024
+// { dg-options -std=c++0x }
+
+template< class T >
+struct Container
+{
+ Container(){
+ int* ptr = new int{};
+ }
+};
+
+int main() {
+ Container< int > c;
+}
+