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 C922F3858296 for ; Mon, 17 Jul 2023 17:45:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C922F3858296 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689615908; 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: in-reply-to:in-reply-to:references:references; bh=wg4453oMDomklXfCGPIx43qltUEOMaCOsM/heyXaxko=; b=Wu6uUQoSqZuaFoTfgz7EoXjwbiMjVWv2aPIhePiq9cIH8vR9E11S/SENaq5sRXOr+jYThF 2lU/zAU0F2AISARpxYSrLGA67cRfnnU95qEMM8EI7fG51ZCe/OzxAwbHY+kV8rGSoR2mtF 4/zSn3E0Gq2VeedK+pdqzceefRNkTVY= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-A_tDD3IKOMy7Gh_VKhkb_g-1; Mon, 17 Jul 2023 13:45:07 -0400 X-MC-Unique: A_tDD3IKOMy7Gh_VKhkb_g-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-635325b87c9so49559476d6.1 for ; Mon, 17 Jul 2023 10:45:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689615907; x=1692207907; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wg4453oMDomklXfCGPIx43qltUEOMaCOsM/heyXaxko=; b=l8nQIQDOaLp6QERNGazdYk2zNHQgyI+uL+UNwdN/0TbDTqDAD6t+HM1/5pkU3zpwVP GTZdTjP0dzJPAS57YdjYNKlsvcW2OLksyJTk+PUtIW30kulNe9cAzQu3dAskTJyLaFzL wwEmM24sYz+mQN8hkdVHjNhMzK1yDubaUJW8DhUx0w96b2sKuKmExJVy/e3mZyAVukTZ 3/+wHzl0f1H23VRDUAW71hGC0i/uG+5ZaVAonPeBQ7wls6kBD+86iaJ07rRM7aNKHoFx w/+BA5qzf06VddAPHzBG4nKWnDbKDhk1syDLo0eA3Yd1nZwtKoVL1fJsb/YZgQ7Q6jLD 5PEQ== X-Gm-Message-State: ABy/qLZ1Jv0SMmqcyG8ZMLCGJ8DoAmTqh2JlTK8Gvz+12tE9dpPusxy0 ElamweCdW5DK1eby8tlHagvDt7U6iFysu635MVVBBBVsd9FEb6p7RdsxA8hZBMym/NnnEvzNAHP JVcXulz0g2F9lx96wfw== X-Received: by 2002:a0c:f04d:0:b0:636:41e6:ae01 with SMTP id b13-20020a0cf04d000000b0063641e6ae01mr11413041qvl.40.1689615907017; Mon, 17 Jul 2023 10:45:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6zmUfQMPNIqcctNy2cQSjVVv5dBQeEagPLFWZm+DxTnhhNv6ZlEexeaOd82gu9bkYmX939Q== X-Received: by 2002:a0c:f04d:0:b0:636:41e6:ae01 with SMTP id b13-20020a0cf04d000000b0063641e6ae01mr11413024qvl.40.1689615906712; Mon, 17 Jul 2023 10:45:06 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id e23-20020a0caa57000000b006255bcfca88sm80180qvb.7.2023.07.17.10.45.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jul 2023 10:45:06 -0700 (PDT) Message-ID: <917b22f4-e9ac-7a2f-bef7-fae96eb10994@redhat.com> Date: Mon, 17 Jul 2023 13:45:05 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] c++: constrained surrogate calls [PR110535] To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20230712154138.2837658-1-ppalka@redhat.com> <5ead72b2-d241-1dbc-b168-63260321683e@idea> From: Jason Merrill In-Reply-To: <5ead72b2-d241-1dbc-b168-63260321683e@idea> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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 7/12/23 11:54, Patrick Palka wrote: > On Wed, 12 Jul 2023, Patrick Palka wrote: > >> We're not checking constraints of pointer/reference-to-function conversion >> functions during overload resolution, which causes us to ICE on the first >> testcase and incorrectly reject the second testcase. > > Er, I noticed [over.call.object] doesn't exactly say that surrogate > call functions inherit the constraints of the corresponding conversion > function, but I reckon that's the intent? I also assume so. OK. >> >> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for >> trunk/13? >> >> PR c++/110535 >> >> gcc/cp/ChangeLog: >> >> * call.cc (add_conv_candidate): Check constraints. >> >> gcc/testsuite/ChangeLog: >> >> * g++.dg/cpp2a/concepts-surrogate1.C: New test. >> * g++.dg/cpp2a/concepts-surrogate2.C: New test. >> --- >> gcc/cp/call.cc | 8 ++++++++ >> gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C | 12 ++++++++++++ >> gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C | 14 ++++++++++++++ >> 3 files changed, 34 insertions(+) >> create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C >> create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C >> >> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc >> index 15a3d6f2a1f..81935b83908 100644 >> --- a/gcc/cp/call.cc >> +++ b/gcc/cp/call.cc >> @@ -2588,6 +2588,14 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj, >> if (*candidates && (*candidates)->fn == totype) >> return NULL; >> >> + if (!constraints_satisfied_p (fn)) >> + { >> + reason = constraint_failure (); >> + viable = 0; >> + return add_candidate (candidates, fn, obj, arglist, len, convs, >> + access_path, conversion_path, viable, reason, flags); >> + } >> + >> for (i = 0; i < len; ++i) >> { >> tree arg, argtype, convert_type = NULL_TREE; >> diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C >> new file mode 100644 >> index 00000000000..e8481a31656 >> --- /dev/null >> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C >> @@ -0,0 +1,12 @@ >> +// PR c++/110535 >> +// { dg-do compile { target c++20 } } >> + >> +using F = int(int); >> + >> +template >> +struct A { >> + operator F*() requires B; >> +}; >> + >> +int i = A{}(0); // OK >> +int j = A{}(0); // { dg-error "no match" } >> diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C >> new file mode 100644 >> index 00000000000..8bf8364beb7 >> --- /dev/null >> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C >> @@ -0,0 +1,14 @@ >> +// PR c++/110535 >> +// { dg-do compile { target c++20 } } >> + >> +using F = int(int); >> +using G = long(int); >> + >> +template >> +struct A { >> + operator F&() requires B; >> + operator G&() requires (!B); >> +}; >> + >> +int i = A{}(0); // { dg-bogus "ambiguous" } >> +int j = A{}(0); // { dg-bogus "ambiguous" } >> -- >> 2.41.0.327.gaa9166bcc0 >> >> >