* [PATCH] c++: ICE when building builtin operator->* set [PR103455]
@ 2022-03-25 18:09 Patrick Palka
2022-03-25 18:49 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-03-25 18:09 UTC (permalink / raw)
To: gcc-patches
When constructing the builtin operator->* candidate set according to
the available conversion functions for each operand type, we end up
considering a candidate with C1=T (a TEMPLATE_TYPE_PARM) and C2=F,
during which we crash from lookup_base because dependent_type_p sees
a TEMPLATE_TYPE_PARM when processing_template_decl is cleared.
Sidestepping the question of whether we should be considering a
dependent conversion function here in the first place (which I'm not
sure about), it seems futile to check DERIVED_FROM_P for anything other
than an actual class type, so this patch fixes this ICE by guarding
the DERIVED_FROM_P test with CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk and perhaps the release branches?
PR c++/103455
gcc/cp/ChangeLog:
* call.cc (add_builtin_candidate) <case MEMBER_REF>: Check
CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.
gcc/testsuite/ChangeLog:
* g++.dg/overload/builtin6.C: New test.
---
gcc/cp/call.cc | 2 +-
gcc/testsuite/g++.dg/overload/builtin6.C | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/overload/builtin6.C
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index ec6c5d5baa2..dfe370d685d 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -2821,7 +2821,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;
diff --git a/gcc/testsuite/g++.dg/overload/builtin6.C b/gcc/testsuite/g++.dg/overload/builtin6.C
new file mode 100644
index 00000000000..25e45040094
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/builtin6.C
@@ -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 foo(B b, F f) {
+ (b->*f)();
+}
--
2.35.1.655.ga68dfadae5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: ICE when building builtin operator->* set [PR103455]
2022-03-25 18:09 [PATCH] c++: ICE when building builtin operator->* set [PR103455] Patrick Palka
@ 2022-03-25 18:49 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2022-03-25 18:49 UTC (permalink / raw)
To: Patrick Palka, gcc-patches
On 3/25/22 14:09, Patrick Palka wrote:
> When constructing the builtin operator->* candidate set according to
> the available conversion functions for each operand type, we end up
> considering a candidate with C1=T (a TEMPLATE_TYPE_PARM) and C2=F,
> during which we crash from lookup_base because dependent_type_p sees
> a TEMPLATE_TYPE_PARM when processing_template_decl is cleared.
>
> Sidestepping the question of whether we should be considering a
> dependent conversion function here in the first place (which I'm not
> sure about), it seems futile to check DERIVED_FROM_P for anything other
> than an actual class type, so this patch fixes this ICE by guarding
> the DERIVED_FROM_P test with CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk and perhaps the release branches?
OK for trunk and branches.
> PR c++/103455
>
> gcc/cp/ChangeLog:
>
> * call.cc (add_builtin_candidate) <case MEMBER_REF>: Check
> CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/overload/builtin6.C: New test.
> ---
> gcc/cp/call.cc | 2 +-
> gcc/testsuite/g++.dg/overload/builtin6.C | 14 ++++++++++++++
> 2 files changed, 15 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/overload/builtin6.C
>
> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
> index ec6c5d5baa2..dfe370d685d 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -2821,7 +2821,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;
> diff --git a/gcc/testsuite/g++.dg/overload/builtin6.C b/gcc/testsuite/g++.dg/overload/builtin6.C
> new file mode 100644
> index 00000000000..25e45040094
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/overload/builtin6.C
> @@ -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 foo(B b, F f) {
> + (b->*f)();
> +}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-25 18:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 18:09 [PATCH] c++: ICE when building builtin operator->* set [PR103455] Patrick Palka
2022-03-25 18:49 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).