maybe_instantiate_noexcept doesn't expect to see error_mark_node, so
the new callsite I introduced in r11-6476 needs to be properly guarded.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

gcc/cp/ChangeLog:

        PR c++/98659
        * pt.c (resolve_overloaded_unification): Don't call
        maybe_instantiate_noexcept with error_mark_node.

gcc/testsuite/ChangeLog:

        PR c++/98659
        * g++.dg/template/deduce8.C: New test.
---
 gcc/cp/pt.c                             |  2 +-
 gcc/testsuite/g++.dg/template/deduce8.C | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/template/deduce8.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 100c35f053c..83ecb0a2c3a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -22382,7 +22382,7 @@ resolve_overloaded_unification (tree tparms,
                  --function_depth;
                }
 
-             if (flag_noexcept_type)
+             if (flag_noexcept_type && fn != error_mark_node)
                maybe_instantiate_noexcept (fn, tf_none);
 
              elem = TREE_TYPE (fn);
diff --git a/gcc/testsuite/g++.dg/template/deduce8.C 
b/gcc/testsuite/g++.dg/template/deduce8.C
new file mode 100644
index 00000000000..430be426689
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/deduce8.C
@@ -0,0 +1,21 @@
+// PR c++/98659
+// { dg-do compile }
+
+template <bool> struct enable_if;
+struct function {
+  template <typename _F> void operator=(_F);
+};
+struct map {
+  function operator[](int);
+};
+enum { E };
+template <typename> void foo ();
+template <typename T>
+typename enable_if<T::value>::type foo ();
+
+void
+bar ()
+{
+  map m;
+  m[E] = foo<int>;
+}

base-commit: 7d7ef413ef1b696dec2710ae0acc058bdc832686
-- 
2.29.2

Reply via email to