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.129.124]) by sourceware.org (Postfix) with ESMTPS id 4A4053870899 for ; Wed, 12 Jun 2024 17:56:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A4053870899 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 4A4053870899 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718215005; cv=none; b=J3+uWAtw87IPshXn5jgKk9uCkWUygOPeZ4a/3PiZPxDinPZlj3+idOJOv+6WBV3f8zAV1ceSWO2hRIlv1QSlaiwZKpePCRsBS6RW4X2zzZwKY0ghWPc/+rWLGmhG0fiuhQ5aseLfbuJvSpNFzta/oycwsHSZcx0dWjUiSPvU7BY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718215005; c=relaxed/simple; bh=8AmDqj47chm0Fe5dPWsrbDREInd4eO9Ht4DnZGgebBQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XRpAoEXBfdT+PxJ+oC7NVm1mHrf9gXB0fsbbrUhmy5KldcrmrvtIukavp0F//ll0sIlfF86gI+CWlaXMxtsXfIaXjd3H1YzMtGMOSwtK8vf331gKgHRRPJ9VZ1oM9jHS7wY2qhP0uVdtBkD6Ef2NRdEiPQTYWNffHxwhSW5OgIQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718215002; 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: content-transfer-encoding:content-transfer-encoding; bh=GSUy2VEuw8PsCyhy3d2NOxltA8kmDwlSL/niSHYgqnU=; b=Lz4pVC2lE1nEOQQQ82UwwTOIPqNqYq01ywkWnOrzMEAlOfsX+STnVP+FRP7xG2cg/oz8e5 4L3IWsQavR4XiMA4f9HfzJxi+eFpg2w211hvnKc4uPUxewLQwmVi0vdqu2K8LHmxG3uxci PgoXJY3Vqr0fJErvvIzeLtulWgWYRvk= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-kYlaUJ71MNmF2pk8JtTDhA-1; Wed, 12 Jun 2024 13:56:41 -0400 X-MC-Unique: kYlaUJ71MNmF2pk8JtTDhA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6b06c8269fcso737436d6.1 for ; Wed, 12 Jun 2024 10:56:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718215000; x=1718819800; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GSUy2VEuw8PsCyhy3d2NOxltA8kmDwlSL/niSHYgqnU=; b=txVR3f6XpE9Ra9bFfbmDixMwHC8C0maZm1ml2OVGEnq5NAwidFWgZl8OqM7KcLbh4s /lWJxUnB4fLTfkdGKaVe+ouIy2cHPFHuFROk8DPpWnXGYXXr5PpQpRzGVT+qRVU/bkL6 zDjak0VDpSfKIQcTbLWKCD5/McA9zqlx8R8L52FfVwqvei0+2P/oKPCwMiGNHSU56X4y ZleB8aKXypfq4awGZWhVk19OU0AwlTcyAS6SATg/hyemBzFgKnWJzZ1h1brbdHF+MoAe efyDuCvEc2F//NvajeoMkWLZW8kgIe7Rw2alqL43UddU+aZhHKx4kxtMp6kNnZD4qqEz 5sbA== X-Gm-Message-State: AOJu0YxvEpWwkQ+Rb/RPMLbmjE1aXISSkLFbsu6u1jciTYF+rmGyqGNR MmXR77S229Y0vQd8eo19dm46jjV0Io50xxDc2NVYrBYDe66McOLV6IQyY4JiYWwJVIyW5RN4o9g aMq3Mt0RL1GUTG9IJpO2SW3JkXR5M915Is5wzHlhScbJxW+Wq84tEa9iw2mURUF0JcuIgNWPjwZ CcBwaNQhE477H9Ykgrx/r94GTOvNrb5tjcpxw7 X-Received: by 2002:a05:6214:5c44:b0:6b0:48:c134 with SMTP id 6a1803df08f44-6b1b5b13600mr24404276d6.51.1718215000119; Wed, 12 Jun 2024 10:56:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpqYpbYSmo9AfDoH44GranvCC/DLv78hQURGax7JsUWzVmxCOoqmJKMYW12NmpVs6o+yhc6g== X-Received: by 2002:a05:6214:5c44:b0:6b0:48:c134 with SMTP id 6a1803df08f44-6b1b5b13600mr24404076d6.51.1718214999695; Wed, 12 Jun 2024 10:56:39 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06d811600sm46713206d6.109.2024.06.12.10.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 10:56:39 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: ICE w/ ambig and non-strictly-viable cands [PR115239] Date: Wed, 12 Jun 2024 13:56:37 -0400 Message-ID: <20240612175637.2714077-1-ppalka@redhat.com> X-Mailer: git-send-email 2.45.2.457.g8d94cfb545 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.4 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: 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" } +} -- 2.45.2.457.g8d94cfb545