Skip to content

Commit c755c7a

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.
1 parent 858918e commit c755c7a

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
@@ -23787,6 +23787,8 @@ resolve_overloaded_unification (tree tparms,
2378723787
for (lkp_iterator iter (arg); iter; ++iter)
2378823788
{
2378923789
tree fn = *iter;
23790+
if (flag_noexcept_type)
23791+
maybe_instantiate_noexcept (fn, tf_none);
2379023792
if (try_one_overload (tparms, targs, tempargs, parm, TREE_TYPE (fn),
2379123793
strict, sub_strict, addr_p, explain_p)
2379223794
&& (!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)