[C++ Patch] PR 70466 ("ICE on invalid code in tree check: expected constructor, have parm_decl in convert_like_real...")

Paolo Carlini paolo.carlini@oracle.com
Tue May 17 08:47:00 GMT 2016


... alternately, if the substance of my patchlet is right, we could 
simplify a bit the logic per the below.

Thanks,
Paolo.

/////////////////////
-------------- next part --------------
Index: cp/call.c
===================================================================
--- cp/call.c	(revision 236309)
+++ cp/call.c	(working copy)
@@ -6377,8 +6377,9 @@ convert_like_real (conversion *convs, tree expr, t
 	/* When converting from an init list we consider explicit
 	   constructors, but actually trying to call one is an error.  */
 	if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)
+	    && BRACE_ENCLOSED_INITIALIZER_P (expr)
 	    /* Unless this is for direct-list-initialization.  */
-	    && !DIRECT_LIST_INIT_P (expr)
+	    && !CONSTRUCTOR_IS_DIRECT_INIT (expr)
 	    /* And in C++98 a default constructor can't be explicit.  */
 	    && cxx_dialect >= cxx11)
 	  {
Index: testsuite/g++.dg/template/crash122.C
===================================================================
--- testsuite/g++.dg/template/crash122.C	(revision 0)
+++ testsuite/g++.dg/template/crash122.C	(working copy)
@@ -0,0 +1,27 @@
+// PR c++/70466
+
+template < class T, class T >  // { dg-error "conflicting" }
+class A
+{
+public:
+  explicit A (T (S::*f) ()) {}  // { dg-error "expected" }
+};
+
+template < class T, class S > 
+A < T, S > foo (T (S::*f) ())
+{
+  return A < T, S > (f);
+}
+
+class B
+{
+public:
+  void bar () {}
+};
+
+int
+main ()
+{
+  foo (&B::bar);
+  return 0;
+}


More information about the Gcc-patches mailing list