diff mbox

C++ PATCH for c++/60951 (ICE with constexpr and aggregate init)

Message ID 53610611.7000207@redhat.com
State New
Headers show

Commit Message

Jason Merrill April 30, 2014, 2:17 p.m. UTC
I'm not sure why I changed the use of maybe_constant_init to 
maybe_constant_value when I added the call to 
fold_non_dependent_expr_sfinae.  And that caused this problem, so I'm 
changing it back.

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

Patch

commit f103a8af382f2dcb3022cdbefa18b963612215f5
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 29 16:57:58 2014 -0400

    	PR c++/60951
    	* typeck2.c (massage_init_elt): Use maybe_constant_init.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 5bbc2efd..044d971 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1138,7 +1138,7 @@  massage_init_elt (tree type, tree init, tsubst_flags_t complain)
   /* When we defer constant folding within a statement, we may want to
      defer this folding as well.  */
   tree t = fold_non_dependent_expr_sfinae (init, complain);
-  t = maybe_constant_value (t);
+  t = maybe_constant_init (t);
   if (TREE_CONSTANT (t))
     init = t;
   return init;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C
new file mode 100644
index 0000000..7e4da11
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C
@@ -0,0 +1,17 @@ 
+// PR c++/60951
+// { dg-do compile { target c++11 } }
+
+struct Foo {
+  constexpr Foo(int x = 0) : memb(x) {}
+  int memb;
+};
+
+struct FooContainer {
+  Foo foo[2];
+};
+
+void fubar() {
+  int nonConst = 0;
+  FooContainer fooContainer;
+  fooContainer = { { 0, nonConst } };
+}