public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7830] c++: ICE when building builtin operator->* set [PR103455] Date: Sat, 26 Mar 2022 14:20:51 +0000 (GMT) [thread overview] Message-ID: <20220326142051.A4A283858D28@sourceware.org> (raw) https://gcc.gnu.org/g:04f19580e8dbdbc7366d0f5fd068aa0cecafdc9d commit r12-7830-g04f19580e8dbdbc7366d0f5fd068aa0cecafdc9d Author: Patrick Palka <ppalka@redhat.com> Date: Sat Mar 26 10:20:16 2022 -0400 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.cc (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. Diff: --- gcc/cp/call.cc | 2 +- gcc/testsuite/g++.dg/overload/builtin6.C | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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..de192be67ec --- /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 f(B b, F pmf) { + (b->*pmf)(); +}
reply other threads:[~2022-03-26 14:20 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220326142051.A4A283858D28@sourceware.org \ --to=ppalka@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).