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 ESMTP id 1C824385ED4A for ; Thu, 29 Apr 2021 13:46:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1C824385ED4A Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-504-UhbAAgGxOiWAYcJGm9AHsg-1; Thu, 29 Apr 2021 09:46:14 -0400 X-MC-Unique: UhbAAgGxOiWAYcJGm9AHsg-1 Received: by mail-qt1-f197.google.com with SMTP id h14-20020ac846ce0000b02901ba21d99130so19188128qto.13 for ; Thu, 29 Apr 2021 06:46:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YIOYIfrhR3mzeKT6Sc1/z2yEmE5wZyxUi3L0xAMzOrI=; b=rkVq5Iifye1ZYviNIHK+ZF3DK67iCn5swDKOjt1EyfgCOwq8LAKngBHa0nT+ByNksw OTYBJ29zhHngoSW4HUW3mMW8DubgqqqnF2zg5QzP9/hI43jlt+3i2sju42F48icl3BK+ 3bvCmz21c2ntB8IZnunpHtj4tB9qYyMldO6p7VCi4gtf/mNU2uYg/gh9wj4dmSJHSZ4W v6PCKPN3mghvylegCiAEbIdCj+LQUpoPfEDHTMQUObWWlILq1cCANV8FEporz6TTntVc C882jhATSMZNOJia/rAO04SoIxjQXwyRLh0gvgGzyWpGCEA688wKX4kvl+exgr/TR5nX CQ2g== X-Gm-Message-State: AOAM533S5QkKP82OKKc9J01c03GGd2CElLKZfKfGMxgzTDDPitm0/PXp HWzRQHKJxv3MeyeoUlI+B3uQ/5Sh+LVeEtQndQPrjzLvwxU9kxmN2ooZXhZs/r8zr/kGv0v53nG o/H7Z8wKWpcIG5vlmvlf4WN8J/jjnVmdsp3JG8UE1LbjagFPxWQdDi+3VtDEruunzYw== X-Received: by 2002:a0c:9e0f:: with SMTP id p15mr34449278qve.27.1619703974054; Thu, 29 Apr 2021 06:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOqjSgsuY4Xss0z4jpZYngV9nKW2GVY70Zme7nxJcpBWNXN1l2jfZkpZ0o2iFgSE9ZKkIxvg== X-Received: by 2002:a0c:9e0f:: with SMTP id p15mr34449248qve.27.1619703973666; Thu, 29 Apr 2021 06:46:13 -0700 (PDT) Received: from [192.168.1.148] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id f2sm2195939qkh.76.2021.04.29.06.46.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Apr 2021 06:46:13 -0700 (PDT) Subject: Re: [PATCH] c++: Overeager use of deleted function before ADL [PR68942] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20210428190309.4143566-1-ppalka@redhat.com> From: Jason Merrill Message-ID: Date: Thu, 29 Apr 2021 09:46:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210428190309.4143566-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-15.5 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2021 13:46:18 -0000 On 4/28/21 3:03 PM, Patrick Palka wrote: > Here, at template definition time, ordinary name lookup for 'foo(t)' > finds the deleted function, and so we form a CALL_EXPR thereof. Later > at instantiation time, when initially substituting into this CALL_EXPR > with T=N::A, we end up calling mark_used on this deleted function before > we augment the overload set via ADL and select the right function. > > This patch fixes this issue by using tf_conv in order to disable > mark_used during the initial substitution of the function of a CALL_EXPR > when KOENIG_P. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? Hmm, I suppose this is close enough to the tf_conv case to make sense, as we're still figuring out which functions are candidates. OK. > gcc/cp/ChangeLog: > > PR c++/68942 > * pt.c (tsubst_copy_and_build) : When KOENIG_P, > add tf_conv to complain during the initial substitution into > the function. > > gcc/testsuite/ChangeLog: > > PR c++/68942 > * g++.dg/template/koenig12.C: New test. > --- > gcc/cp/pt.c | 6 +++++- > gcc/testsuite/g++.dg/template/koenig12.C | 15 +++++++++++++++ > 2 files changed, 20 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/template/koenig12.C > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > index d79fecd4949..bed9a22193a 100644 > --- a/gcc/cp/pt.c > +++ b/gcc/cp/pt.c > @@ -20238,7 +20238,11 @@ tsubst_copy_and_build (tree t, > /* Avoid error about taking the address of a constructor. */ > function = TREE_OPERAND (function, 0); > > - function = tsubst_copy_and_build (function, args, complain, > + /* When KOENIG_P, we don't want to mark_used a function until > + after performing ADL, during this substitution we disable > + mark_used by adding tf_conv to complain (68942). */ > + function = tsubst_copy_and_build (function, args, > + complain | (koenig_p * tf_conv), > in_decl, > !qualified_p, > integral_constant_expression_p); > diff --git a/gcc/testsuite/g++.dg/template/koenig12.C b/gcc/testsuite/g++.dg/template/koenig12.C > new file mode 100644 > index 00000000000..fd05ef5719e > --- /dev/null > +++ b/gcc/testsuite/g++.dg/template/koenig12.C > @@ -0,0 +1,15 @@ > +// PR c++/68942 > +// { dg-do compile { target c++11 } } > + > +void foo(...) = delete; > + > +template void lookup(T t) { foo(t); } > + > +namespace N { > + struct A { }; > + int foo(A); > +} > + > +int main() { > + lookup(N::A{}); > +} >