This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/61445 (ICE with local class)

When I fixed 56947 in 4.7, I added an assert to make sure that the trunk was being sensible in the way I expected: local class member functions are supposed to be instantiated from the TAG_DEFN. But we can get to instantiate_decl before that if it's used from another local class member function, so the assert is wrong; let's just remove it.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 3115f729a22d8244965b68807561eef04019757a
Author: Jason Merrill <>
Date:   Mon Jul 14 01:39:33 2014 -0400

    	PR c++/61445
    	PR c++/56947
    	* pt.c (instantiate_decl): Don't check defer_ok for local class

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7b79280..b32cf6c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19775,11 +19775,6 @@ instantiate_decl (tree d, int defer_ok,
   if (external_p && !always_instantiate_p (d))
     return d;
-  /* Any local class members should be instantiated from the TAG_DEFN
-     with defer_ok == 0.  */
-  gcc_checking_assert (!defer_ok || !decl_function_context (d)
-		       || LAMBDA_TYPE_P (DECL_CONTEXT (d)));
   gen_tmpl = most_general_template (tmpl);
   gen_args = DECL_TI_ARGS (d);
diff --git a/gcc/testsuite/g++.dg/template/local9.C b/gcc/testsuite/g++.dg/template/local9.C
new file mode 100644
index 0000000..90f14bb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/local9.C
@@ -0,0 +1,15 @@
+// PR c++/61445
+template <typename T> void f (T)
+  struct A
+  {
+    struct B { B(); };
+    void g () { B b; }
+  };
+int main()
+  f(0);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]