diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 123f06b1f2b..7d12fea60f2 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1449,7 +1449,9 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, tree fbase = class_of_this_parm (fromfn); tree tbase = class_of_this_parm (tofn); - if (!DERIVED_FROM_P (fbase, tbase)) + /* If FBASE and TBASE are equivalent but incomplete, DERIVED_FROM_P + yields false. But a pointer to member of incomplete class is OK. */ + if (!same_type_p (fbase, tbase) && !DERIVED_FROM_P (fbase, tbase)) return NULL; tree fstat = static_fn_type (fromfn); diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type23.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type23.C new file mode 100644 index 00000000000..612dd6ceb5e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type23.C @@ -0,0 +1,14 @@ +// PR c++/99374 +// { dg-do compile { target c++17 } } + +struct S; +struct R; +using F1 = int (S::*)(); +using F2 = int (S::*)() noexcept; +using F3 = int (R::*)() noexcept; +using T = S; +using F4 = int (T::*)() noexcept; +F1 f21 = F2(); +F1 f41 = F4(); +F2 f12 = F1(); // { dg-error "cannot convert" } +F1 f31 = F3(); // { dg-error "cannot convert" }