Patchwork [C++] PR 46117

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 21, 2010, 5:11 p.m.
Message ID <4CC0744B.4050409@oracle.com>
Download mbox | patch
Permalink /patch/68730/
State New
Headers show

Comments

Paolo Carlini - Oct. 21, 2010, 5:11 p.m.
Hi,

this is a conservative - ie, essentially the "kludge" branch disappears
when parmlist is null and we are back to the exact 4.5 code path -
patchlet for this Segfault, new in 4.6 of course. Tested x86_64-linux.

Ok for mainline?

Thanks,
Paolo.

///////////////////////
/cp
2010-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/46117
	* call.c (add_function_candidate): Don't use TREE_VALUE on null
	parmnode.

/testsuite
2010-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/46117
	* g++.dg/parse/crash57.C: New.
Jason Merrill - Oct. 21, 2010, 7:03 p.m.
OK.

Jason

Patch

Index: testsuite/g++.dg/parse/crash57.C
===================================================================
--- testsuite/g++.dg/parse/crash57.C	(revision 0)
+++ testsuite/g++.dg/parse/crash57.C	(revision 0)
@@ -0,0 +1,10 @@ 
+// PR c++/46117
+
+struct A
+{
+  A (typename int); // { dg-error "before|declaration" }
+};
+
+struct B : A {};
+
+B b;
Index: cp/call.c
===================================================================
--- cp/call.c	(revision 165779)
+++ cp/call.c	(working copy)
@@ -1613,9 +1613,10 @@  add_function_candidate (struct z_candidate **candi
   /* Kludge: When looking for a function from a subobject while generating
      an implicit copy/move constructor/operator=, don't consider anything
      that takes (a reference to) an unrelated type.  See c++/44909.  */
-  else if ((flags & LOOKUP_SPECULATIVE)
-	   || (current_function_decl
-	       && DECL_DEFAULTED_FN (current_function_decl)))
+  else if (parmlist
+	   && ((flags & LOOKUP_SPECULATIVE)
+	       || (current_function_decl
+		   && DECL_DEFAULTED_FN (current_function_decl))))
     {
       if (DECL_CONSTRUCTOR_P (fn))
 	i = 1;