From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DC63D3870899 for ; Wed, 12 Jun 2024 17:59:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC63D3870899 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC63D3870899 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718215209; cv=none; b=a5qeOsY5gE4KzQKP0GXgucXlUFCXzBqk8BrPXRseetvhxplLXl0XHW6yKCQW2eSzudKwB8zmiSmukBatKgQDYrbe+je0OvyxdoUIC1dqj+P/uuoy2NI5pkfTEfUOilSE7NaBpdgrhiPfVzHTj3cCIe62VKtEhLq58jrSKW0XDU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718215209; c=relaxed/simple; bh=pvC7ZLNSefK/mS9+Aq1lerdTjFPI0t05Uiqx2ERPJX8=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=GKnzWNkMjzjKrmAmaGe1wt1mjwCKjeT1qgTXFgrDLLSEhmFvafxujuTWtbb3lstKxJqXeasQGwuqrr4NWiMFMvMt/RnPW+IBwB0T5RPq5FIh/nT/2YvH5PNHZ6ZZ5wsiOcAVGPSagl77owp69SxNPpGrWQUHqW92SVzcgP4DMCg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718215199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=batEkhpVVCcS2UTjWdRD8OrUYvHGWp9APy7FdbdYYso=; b=QDvl/ENCEdmJqVTJHJFPQu7zdr/Fm2hG6mRT1VHFSXr8v021dvj05xl0upOnbHEwmQxHIO erWkQ1nttJL4wu/hEK5W66HbgY+jcOgxr3V3Pgp2L5ases9PI7IlbBfuZviS0fRzyRAife VwuRlilz6ci+qHS761H61VsQf7DTWLI= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-woEJB0EMP0-C2AT7mtEX4A-1; Wed, 12 Jun 2024 13:59:57 -0400 X-MC-Unique: woEJB0EMP0-C2AT7mtEX4A-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-79784eb58cdso5393985a.0 for ; Wed, 12 Jun 2024 10:59:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718215197; x=1718819997; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=batEkhpVVCcS2UTjWdRD8OrUYvHGWp9APy7FdbdYYso=; b=iqlSlRn21BtNt7u3+RRlc5sJ0ZZLNbqpuXGykVvdSCF/3I4lPoL+1p51KI4a/okMZI nLc0VqZ9tbIqJ8FS6ZWiFwzmUhHE7CdRALbng1UHhAiIs6S6EAmnEkUoxTDVf2jCYD/V qIxBN1TSSJvos8dqOiMc9ZkKYXnVrN287bbm7S6ascQCWSiyKHilBKv2G7jzAa1+2+4V xeJlGw8Z4h13cS+dAUB2AwF5gV2JPfwBbjTiJbH0WQmqbzAMBdwvjuPFcYM4ZMl7uocS xBSSkyvAGhv0nWIaztxOi6uOGcCDlIhxY9vl1UO+kPsRSYhSXQ4vZRcUKxrRQt2vVLL2 dqJw== X-Gm-Message-State: AOJu0YxuMMblgzQOj+DiUya7PXpfqGt+AilJWaYT8f9I8uYZ/FCXcxgS 8pv8orv3pjcEPD64X/WSGBwpgbNf40747WfegTjfjg2zedwnqlu4W2/+kEg3DiaU9ieWY2dj/5P SayrCItHxE+zKIv588vGK+I32eH6c9RdOTeLiQ1pJEYN3SNT+pFqP5h4= X-Received: by 2002:a05:620a:1912:b0:795:601e:c10 with SMTP id af79cd13be357-797f6036155mr291659185a.33.1718215196911; Wed, 12 Jun 2024 10:59:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm1uBNePmjkg/qyCATg0vqywEMfOdPMGAWKrgPW7c4RJ0wNlkY6P1D54NAA/lgN1zOWudIjA== X-Received: by 2002:a05:620a:1912:b0:795:601e:c10 with SMTP id af79cd13be357-797f6036155mr291657285a.33.1718215196554; Wed, 12 Jun 2024 10:59:56 -0700 (PDT) Received: from [192.168.1.130] (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id af79cd13be357-795556462b7sm413588885a.95.2024.06.12.10.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 10:59:56 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Wed, 12 Jun 2024 13:59:55 -0400 (EDT) To: Patrick Palka cc: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: Re: [PATCH] c++: ICE w/ ambig and non-strictly-viable cands [PR115239] In-Reply-To: <20240612175637.2714077-1-ppalka@redhat.com> Message-ID: <4bf33e1b-0e08-79ec-0807-83395d3a3587@idea> References: <20240612175637.2714077-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 12 Jun 2024, 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)) > { > champ = nullptr; > break; > diff --git a/gcc/testsuite/g++.dg/overload/error7.C b/gcc/testsuite/g++.dg/overload/error7.C > new file mode 100644 > index 00000000000..68aaa236de4 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/overload/error7.C > @@ -0,0 +1,10 @@ > +// PR c++/115239 > + > +bool foo(const char *, char *, long); // #1, strictly viable, ambig with #2 > +bool foo(const char *, char *, unsigned); // #2, strictly viable, ambig with #1 > +bool foo(char, char, long); // #3, non-strictly viable > +bool foo(char, char, unsigned); // #4, non-strictly viable > + > +int main() { > + foo((char *)0, (char *)0, 0); // { dg-error "ambiguous" } > +} FWIW I just realized this testcase can be simplified to: // PR c++/115239 bool foo(char *, long); // #1, strictly viable, ambig with #2 bool foo(char *, unsigned); // #2, strictly viable, ambig with #1 bool foo(char, long); // #3, non-strictly viable bool foo(char, unsigned); // #4, non-strictly viable int main() { foo((char *)0, 0); // { dg-error "ambiguous" } }