===================================================================
@@ -17857,6 +17857,8 @@ unify (tree tparms, tree targs, tree parm, tree ar
if (!BRACE_ENCLOSED_INITIALIZER_P (elt))
{
tree type = TREE_TYPE (elt);
+ if (type == error_mark_node)
+ return unify_invalid (explain_p);
/* It should only be possible to get here for a call. */
gcc_assert (elt_strict & UNIFY_ALLOW_OUTER_LEVEL);
elt_strict |= maybe_adjust_types_for_deduction
===================================================================
@@ -0,0 +1,10 @@
+// PR c++/58614
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+void foo()
+{
+ i; // { dg-error "not declared" }
+ auto j = { i }; // { dg-error "unable to deduce" }
+}