diff mbox

C++ PATCH for c++/49507 (ICE with template dtor defaulted out of class)

Message ID 4E036FB2.5050706@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 23, 2011, 4:54 p.m. UTC
Here, if we're going to synthesize the dtor in instantiate_decl, we need 
to not also do it directly in mark_used.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.1 (since Jakub 
asked about fixing this for 4.6.1 and it seems safe).
diff mbox

Patch

commit 2c7d73cc244974ee3e483cdfcddc210fdf98e25a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 23 11:06:43 2011 -0400

    	PR c++/49507
    	* decl2.c (mark_used): Don't call synthesize_method for
    	functions defaulted outside the class.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index d2f075d..9e5a229 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4297,6 +4297,9 @@  mark_used (tree decl)
   if (TREE_CODE (decl) == FUNCTION_DECL
       && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
       && DECL_DEFAULTED_FN (decl)
+      /* A function defaulted outside the class is synthesized either by
+	 cp_finish_decl or instantiate_decl.  */
+      && !DECL_DEFAULTED_OUTSIDE_CLASS_P (decl)
       && ! DECL_INITIAL (decl))
     {
       /* Remember the current location for a function we will end up
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted30.C b/gcc/testsuite/g++.dg/cpp0x/defaulted30.C
new file mode 100644
index 0000000..0bf4425
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted30.C
@@ -0,0 +1,16 @@ 
+// PR c++/49507
+// { dg-options -std=c++0x }
+
+template<typename T>
+struct ConcretePoolKey
+{
+        virtual ~ConcretePoolKey();
+};
+
+template<typename T>
+ConcretePoolKey<T>::~ConcretePoolKey() = default;
+
+int main()
+{
+        ConcretePoolKey<int> foo;
+}