re PR c++/66320 (ICE: in cxx_eval_constant_expression, at cp/constexpr.c:3524)
authorJason Merrill <jason@redhat.com>
Sun, 31 May 2015 20:36:18 +0000 (16:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 31 May 2015 20:36:18 +0000 (16:36 -0400)
PR c++/66320
* constexpr.c (cxx_eval_constant_expression): Treat a placeholder
with the wrong type as non-constant.

From-SVN: r223901

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/nsdmi11.C [new file with mode: 0644]

index 774c36e53792897ec048757711470cf9eec29397..5029f8320b910f94246a45a16ec439ff8452abde 100644 (file)
@@ -1,3 +1,9 @@
+2015-05-31  Jason Merrill  <jason@redhat.com>
+
+       PR c++/66320
+       * constexpr.c (cxx_eval_constant_expression): Treat a placeholder
+       with the wrong type as non-constant.
+
 2015-05-27  Jason Merrill  <jason@redhat.com>
 
        * decl.c (check_redeclaration_exception_specification): Depend on
index f35ec1e013f39c6903abd06f86976e719c883244..f343ea7eae0a06fa2450ac0a379c376af2ac31c6 100644 (file)
@@ -3458,7 +3458,9 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
       break;
 
     case PLACEHOLDER_EXPR:
-      if (!ctx || !ctx->ctor || (lval && !ctx->object))
+      if (!ctx || !ctx->ctor || (lval && !ctx->object)
+         || !(same_type_ignoring_top_level_qualifiers_p
+              (TREE_TYPE (t), TREE_TYPE (ctx->ctor))))
        {
          /* A placeholder without a referent.  We can get here when
             checking whether NSDMIs are noexcept, or in massage_init_elt;
@@ -3473,8 +3475,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
             use ctx->object unconditionally, but using ctx->ctor when we
             can is a minor optimization.  */
          tree ctor = lval ? ctx->object : ctx->ctor;
-         gcc_assert (same_type_ignoring_top_level_qualifiers_p
-                     (TREE_TYPE (t), TREE_TYPE (ctor)));
          return cxx_eval_constant_expression
            (ctx, ctor, lval,
             non_constant_p, overflow_p);
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi11.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi11.C
new file mode 100644 (file)
index 0000000..29942b0
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/66320
+// { dg-do compile { target c++11 } }
+
+class A
+{
+  virtual int m_fn1 ();
+};
+class B
+{
+public:
+  B (int);
+};
+class D : B
+{
+  struct C
+  {
+    A a;
+    A b = a;
+  };
+  D (int *);
+  C _channels;
+};
+D::D (int *) : B (0) {}