c++: ICE when building builtin operator->* set [PR103455]
Here when constructing the builtin operator->* candidate set according
to the available conversion functions for the operand types, we end up
considering a candidate with C1=T (through B's dependent conversion
function) and C2=F, during which we crash from DERIVED_FROM_P because
dependent_type_p sees a TEMPLATE_TYPE_PARM outside of a template
context.
Sidestepping the question of whether we should be considering such a
dependent conversion function here in the first place, it seems futile
to test DERIVED_FROM_P for anything other than an actual class type, so
this patch fixes this ICE by simply guarding the DERIVED_FROM_P test
with CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.
PR c++/103455
gcc/cp/ChangeLog:
* call.c (add_builtin_candidate) <case MEMBER_REF>: Test
CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.
gcc/testsuite/ChangeLog:
* g++.dg/overload/builtin6.C: New test.
(cherry picked from commit 04f19580e8
)
This commit is contained in:
parent
4df77364f7
commit
3d1c151bc1
|
@ -2684,7 +2684,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
|
|||
tree c1 = TREE_TYPE (type1);
|
||||
tree c2 = TYPE_PTRMEM_CLASS_TYPE (type2);
|
||||
|
||||
if (MAYBE_CLASS_TYPE_P (c1) && DERIVED_FROM_P (c2, c1)
|
||||
if (CLASS_TYPE_P (c1) && DERIVED_FROM_P (c2, c1)
|
||||
&& (TYPE_PTRMEMFUNC_P (type2)
|
||||
|| is_complete (TYPE_PTRMEM_POINTED_TO_TYPE (type2))))
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// PR c++/103455
|
||||
|
||||
struct A { };
|
||||
|
||||
struct B {
|
||||
operator A*() const;
|
||||
template<class T> operator T*() const;
|
||||
};
|
||||
|
||||
typedef void (A::*F)();
|
||||
|
||||
void f(B b, F pmf) {
|
||||
(b->*pmf)();
|
||||
}
|
Loading…
Reference in New Issue