Hi!

The following testcase ICEs because dfs_accumulate_vtbl_inits
creates a POINTER_PLUS_EXPR (not type dependent) which is then fed
through tsubst_copy_and_build during instantiation.

The following patch teaches tsubst_copy_and_build to handle it.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8?

2013-12-03  Jakub Jelinek  <ja...@redhat.com>

        PR c++/59268
        * pt.c (tsubst_copy_and_build): Handle POINTER_PLUS_EXPR.

        * g++.dg/cpp0x/constexpr-template6.C: New test.

--- gcc/cp/pt.c.jj      2013-11-25 18:30:19.000000000 +0100
+++ gcc/cp/pt.c 2013-12-03 17:24:57.276468904 +0100
@@ -14159,6 +14159,10 @@ tsubst_copy_and_build (tree t,
        RETURN (r);
       }
 
+    case POINTER_PLUS_EXPR:
+      return fold_build_pointer_plus (RECUR (TREE_OPERAND (t, 0)),
+                                     RECUR (TREE_OPERAND (t, 1)));
+
     case SCOPE_REF:
       RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,
                                  /*address_p=*/false));
--- gcc/testsuite/g++.dg/cpp0x/constexpr-template6.C.jj 2013-12-03 
17:27:59.896539499 +0100
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-template6.C    2013-12-03 
17:26:56.000000000 +0100
@@ -0,0 +1,20 @@
+// PR c++/59268
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+template <typename>
+struct A
+{
+  constexpr A (int) {}
+  virtual void foo ()
+  {
+    constexpr A<void> a (0);
+  }
+};
+
+void
+bar ()
+{
+  A<int> a (3);
+  a.foo ();
+}

        Jakub

Reply via email to