From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: ICE w/ ambig and non-strictly-viable cands [PR115239]
Date: Wed, 12 Jun 2024 23:27:00 -0400 [thread overview]
Message-ID: <c0f58448-038c-4b50-b892-cc171de717d7@redhat.com> (raw)
In-Reply-To: <20240612175637.2714077-1-ppalka@redhat.com>
On 6/12/24 13:56, Patrick Palka wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk/14?
>
> -- >8 --
>
> Here during overload resolution we have two strictly viable ambiguous
> candidates #1 and #2, and two non-strictly viable candidates #3 and #4
> which we hold on to ever since r14-6522. These latter candidates have
> an empty third arg conversion since the second arg conversion was deemed
> bad. This ends up causing an ICE during joust for #3 and #4 due to this
> empty arg conversion.
>
> We can fix this by making joust robust to empty arg conversions, but in
> this situation we shouldn't need to compare #3 and #4 at all given that
> we have a strictly viable candidate. To that end, this patch makes
> tourney shortcut considering non-strictly viable candidates upon
> encountering ambiguity between two strictly viable candidates, taking
> advantage of the fact that the candidates list is sorted according to
> viability via splice_viable.
>
> PR c++/115239
>
> gcc/cp/ChangeLog:
>
> * call.cc (tourney): Don't consider a non-strictly viable
> candidate as the champ if there was ambiguity between two
> strictly viable candidates.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/overload/error7.C: New test.
> ---
> gcc/cp/call.cc | 4 +++-
> gcc/testsuite/g++.dg/overload/error7.C | 10 ++++++++++
> 2 files changed, 13 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/overload/error7.C
>
> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
> index ed68eb3c568..82c70f5c39f 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -13484,9 +13484,11 @@ tourney (struct z_candidate *candidates, tsubst_flags_t complain)
> }
> else
> {
> + z_candidate *prev_champ = *champ;
> previous_worse_champ = nullptr;
> champ = &(*challenger)->next;
> - if (!*champ || !(*champ)->viable)
> + if (!*champ || !(*champ)->viable
> + || (prev_champ->viable == 1 && (*champ)->viable == -1))
Maybe
(!*champ || (*champ)->viable < prev_champ->viable) ?
OK with that change.
Jason
next prev parent reply other threads:[~2024-06-13 3:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 17:56 Patrick Palka
2024-06-12 17:59 ` Patrick Palka
2024-06-13 3:27 ` Jason Merrill [this message]
2024-06-13 14:07 ` Patrick Palka
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=c0f58448-038c-4b50-b892-cc171de717d7@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ppalka@redhat.com \
/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: link
Be 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).