I had a strong sense of deja vu when looking into this, and no wonder,
since this is almost identical to c++/95728.
Since r11-423 tsubst_copy_and_build/TREE_LIST uses tsubst_tree_list
instead of open coding it. While the latter could return an error
node wrapped in a TREE_LIST, the former can return a naked error node.
That broke in tsubst_copy_and_build/NEW_EXPR, because we were accessing
TREE_VALUE of an error node.
gcc/cp/ChangeLog:
PR c++/97187
PR c++/97993
* pt.c (tsubst_copy_and_build) <case NEW_EXPR>: Return error_mark_node
if init is erroneous.
gcc/testsuite/ChangeLog:
PR c++/97187
PR c++/97993
* g++.dg/eh/crash2.C: New test.
* g++.dg/template/crash132.C: New test.
parameter packs are of length zero. */
if (init == NULL_TREE && TREE_OPERAND (t, 3) == NULL_TREE)
init_vec = NULL;
+ else if (init == error_mark_node)
+ RETURN (error_mark_node);
else
{
init_vec = make_tree_vector ();
--- /dev/null
+// PR c++/97187
+// { dg-do compile { target c++14 } }
+// { dg-options "-fno-exceptions" }
+
+auto yp = [] { return 0; };
+
+template <class DI>
+DI
+zl ()
+{
+ auto au = [] () -> DI { return *new auto (true ? yp : throw); }; // { dg-error "exception handling disabled" }
+
+ return au ();
+}
+
+auto
+vd ()
+{
+ return zl <decltype (yp)> ();
+}
--- /dev/null
+// PR c++/97993
+// { dg-do compile { target c++14 } }
+
+template <class T> T a;
+template <class T, class A, class=decltype(::new T (A()))> auto foo ();
+struct S decltype (foo <int, S>); // { dg-error "" }