Skip to content

Commit 3fe6135

Browse files
committed
c++: noexcept and pointer to member function type [PR113108]
We ICE in nothrow_spec_p because it got a DEFERRED_NOEXCEPT. This DEFERRED_NOEXCEPT was created in implicitly_declare_fn when declaring Foo& operator=(Foo&&) = default; in the test. The problem is that in resolve_overloaded_unification we call maybe_instantiate_noexcept before try_one_overload only in the TEMPLATE_ID_EXPR case. PR c++/113108 gcc/cp/ChangeLog: * pt.cc (resolve_overloaded_unification): Call maybe_instantiate_noexcept. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/noexcept-type28.C: New test. (cherry picked from commit c755c7a)
1 parent df3ae94 commit 3fe6135

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

gcc/cp/pt.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23799,6 +23799,8 @@ resolve_overloaded_unification (tree tparms,
2379923799
for (lkp_iterator iter (arg); iter; ++iter)
2380023800
{
2380123801
tree fn = *iter;
23802+
if (flag_noexcept_type)
23803+
maybe_instantiate_noexcept (fn, tf_none);
2380223804
if (try_one_overload (tparms, targs, tempargs, parm, TREE_TYPE (fn),
2380323805
strict, sub_strict, addr_p, explain_p)
2380423806
&& (!goodfn || !decls_match (goodfn, fn)))
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// PR c++/113108
2+
// { dg-do compile { target c++17 } }
3+
4+
template <typename T>
5+
struct Foo {
6+
Foo& operator=(Foo&&) = default;
7+
T data;
8+
};
9+
10+
template <typename T>
11+
void consume(Foo<T>& (Foo<T>::*)(Foo<T>&&) ) {}
12+
13+
template <typename T>
14+
void consume(Foo<T>& (Foo<T>::*)(Foo<T>&&) noexcept) {}
15+
16+
int main() {
17+
consume(&Foo<int>::operator=);
18+
}

0 commit comments

Comments
 (0)