Hi,

as I said in the audit trail, in its way this error recovery issue is somewhat interesting: Jason's r251422 added some code at the beginning of tsubst_default_argument, included the gcc_assert that triggers here. In fact, parmtype is only used in the assertion thus the error recovery check could be moved inside the assertion, something like (appears to also pass testing, lightly tested, so far):

gcc_assert (parmtype == error_mark_node || same_type_ignoring_top_level_qualifiers_p (type, parmtype));

and for this bug we would be back to the gcc-7 status, thus we would not ICE and we would issue *2* errors, one for the parameter and then one more for the default argument itself, at instantiation time. In fact, some other compilers also do that. Or, as I have below, we can return early, after the first error. Tested x86_64-linux.

Thanks, Paolo.

///////////////////

/cp
2018-03-28  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/85028
        * pt.c (tsubst_default_argument): Early return if the type of the
        parameter is erroneous.

/testsuite
2018-03-28  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/85028
        * g++.dg/other/default13.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 258915)
+++ cp/pt.c     (working copy)
@@ -12337,6 +12337,9 @@ tsubst_default_argument (tree fn, int parmnum, tre
   tree parmtype = TREE_TYPE (parm);
   if (DECL_BY_REFERENCE (parm))
     parmtype = TREE_TYPE (parmtype);
+  if (parmtype == error_mark_node)
+    return error_mark_node;
+
   gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, parmtype));
 
   tree *slot;
Index: testsuite/g++.dg/other/default13.C
===================================================================
--- testsuite/g++.dg/other/default13.C  (nonexistent)
+++ testsuite/g++.dg/other/default13.C  (working copy)
@@ -0,0 +1,11 @@
+// PR c++/85028
+
+struct A;
+
+template < typename > struct B
+{
+  B (int, A = A()) : f (0) {}  // { dg-error "incomplete type" }
+  int f;
+};
+
+B < int > b (0);

Reply via email to