Hi,

in this ICE during error recovery, the check in convert_like_real:

        if (CONSTRUCTOR_NELTS (expr) == 0
        && FUNCTION_FIRST_USER_PARMTYPE (convfn) != void_list_node)

is reached for a PARM_DECL as expr. I think that the correct way to avoid in general such problem is adding (here too, as elsewhere) a check that BRACE_ENCLOSED_INITIALIZER_P (expr) is true to the outer conditional, for sure because talking about "converting to %qT from initializer list would use explicit constructor %qD", which happens anyway in the above conditional, otherwise doesn't make sense. Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
/cp
2016-05-16  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/70466
        * call.c (convert_like_real): Check that we are actually converting
        from an init list.

/testsuite
2016-05-16  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/70466
        * g++.dg/template/crash122.C: New.
Index: cp/call.c
===================================================================
--- cp/call.c   (revision 236300)
+++ cp/call.c   (working copy)
@@ -6377,6 +6377,7 @@ 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)
            /* And in C++98 a default constructor can't be explicit.  */
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;
+}

Reply via email to