Hi,

I think that in order to implement the resolution we simply have to remove the check. Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////
/cp
2014-09-01  Paolo Carlini  <paolo.carl...@oracle.com>

        DR 1405
        PR c++/58102
        * semantics.c (cxx_eval_outermost_constant_expr): Do not check
        for mutable sub-objects.

/testsuite
2014-09-01  Paolo Carlini  <paolo.carl...@oracle.com>

        DR 1405
        PR c++/58102
        * g++.dg/cpp0x/constexpr-mutable2.C: New.
        * g++.dg/cpp0x/constexpr-mutable1.C: Adjust.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 214779)
+++ cp/semantics.c      (working copy)
@@ -9858,18 +9858,6 @@ cxx_eval_outermost_constant_expr (tree t, bool all
 
   verify_constant (r, allow_non_constant, &non_constant_p, &overflow_p);
 
-  if (TREE_CODE (t) != CONSTRUCTOR
-      && cp_has_mutable_p (TREE_TYPE (t)))
-    {
-      /* We allow a mutable type if the original expression was a
-        CONSTRUCTOR so that we can do aggregate initialization of
-        constexpr variables.  */
-      if (!allow_non_constant)
-       error ("%qT cannot be the type of a complete constant expression "
-              "because it has mutable sub-objects", TREE_TYPE (t));
-      non_constant_p = true;
-    }
-
   /* Technically we should check this for all subexpressions, but that
      runs into problems with our internal representation of pointer
      subtraction and the 5.19 rules are still in flux.  */
Index: testsuite/g++.dg/cpp0x/constexpr-mutable1.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-mutable1.C (revision 214785)
+++ testsuite/g++.dg/cpp0x/constexpr-mutable1.C (working copy)
@@ -7,6 +7,6 @@ struct A
 };
 
 constexpr A a = { 0, 1 };
-constexpr A b = a;             // { dg-error "mutable" }
+constexpr A b = a;
 constexpr int i = a.i;
 constexpr int j = a.j;         // { dg-error "mutable" }
Index: testsuite/g++.dg/cpp0x/constexpr-mutable2.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-mutable2.C (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-mutable2.C (working copy)
@@ -0,0 +1,10 @@
+// DR 1405, PR c++/58102
+// { dg-do compile { target c++11 } }
+
+struct S {
+  mutable int n;
+  constexpr S() : n() {}
+};
+
+constexpr S s1 {};
+constexpr S s2 = {};

Reply via email to