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 B8D233858C52 for ; Thu, 2 Feb 2023 22:46:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8D233858C52 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=1675377983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YFdUB1OWxxLfSuMTpmaqmWzpe1gxB9dMSchp/4MfNKA=; b=AykSSVJvmMM8JcvQKSXcSVRNE6MyMML9vVfBBe5oyICQ2BlFGw1DEXkwRhZZu2qp04ZffH X4iJEchkQkUp++yrps/gDhUSIVMFBNHgbe1f+f2nbWraN0gY8rdITtHEGEQtAelZDSgpEq A1X6mIdojUnkzm0OIptVM2jgJuJXqDM= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-543-wdiVHT-0NfSmRb4aLB1Unw-1; Thu, 02 Feb 2023 17:46:22 -0500 X-MC-Unique: wdiVHT-0NfSmRb4aLB1Unw-1 Received: by mail-qk1-f199.google.com with SMTP id h13-20020a05620a244d00b006fb713618b8so2260852qkn.0 for ; Thu, 02 Feb 2023 14:46:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references: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=YFdUB1OWxxLfSuMTpmaqmWzpe1gxB9dMSchp/4MfNKA=; b=qNLZslUVpn0d9CnLSkXsgxeBZbLDX33r4ZL3HDIX35/eBkz3nS5w5MKVe7qu6tg543 fnBDmYiBJDOqYnV483UBeEB71nWdwSEJ2729sMGBcGSpecTHklNu+rC4N9p8Spzz63Zj ClsOv5xUjFIIMc22uIPW2uezToTDieuX9ldlgSlYuiJ5jgz/DJgiEsk8oF4fpBHS8hvL qmMmskoD5IRgv30CK+0OsbCj7ycRzST0+mj9q+XBDh1mn1vI1Lul3P6s4aMpDsFlxlP6 1eMGDEf6uC3mzO8spaWJ03qjAjQVMTeBRKndVNHYerOe7xjQKBubObGzVgMqNttwI4TJ OpHg== X-Gm-Message-State: AO0yUKVaO1rZwvrgMK4vx/RKxiNTamf59XsAKq4+LUMHt4n5umxIqqXr kIKKz7wx5dONQCdMst2JC4DqZbLMlwxThkleF8bnItvdM5ag5Tt5sFHs9dOSnTOr4YIacbLx91n yQ4Rz2dOCzRiw0Swwog== X-Received: by 2002:ac8:5e06:0:b0:3b8:3c0b:6332 with SMTP id h6-20020ac85e06000000b003b83c0b6332mr14671756qtx.28.1675377981590; Thu, 02 Feb 2023 14:46:21 -0800 (PST) X-Google-Smtp-Source: AK7set/w/YCdA6fyy6lShw+PEQwAfLVPuVH/Oan7a0W3s1zCisfb7SDI+zNSauHsYM7BachUxyFmqA== X-Received: by 2002:ac8:5e06:0:b0:3b8:3c0b:6332 with SMTP id h6-20020ac85e06000000b003b83c0b6332mr14671694qtx.28.1675377980970; Thu, 02 Feb 2023 14:46:20 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id dt23-20020a05620a479700b0071a49ac0e05sm553936qkb.111.2023.02.02.14.46.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Feb 2023 14:46:20 -0800 (PST) Message-ID: <21826494-3741-23f0-0797-10a812b58f7d@redhat.com> Date: Thu, 2 Feb 2023 17:46:19 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] c++: excessive satisfaction in check_methods [PR108579] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20230130191038.2450035-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20230130191038.2450035-1-ppalka@redhat.com> 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.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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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 1/30/23 14:10, Patrick Palka wrote: > In check_methods we're unnecessarily checking satisfaction for all > constructors and assignment operators, even those that don't look like > copy/move special members. In the testcase below this manifests as an > unstable satisfaction error because the satisfaction result is first > determined to be false during check_methods (since A is incomplete > at this point) and later true after completion of A. > > This patch fixes this simply by swapping the order of the > constraint_satisfied_p and copy_fn_p / move_fn_p tests. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look > OK for trunk? This doesn't fix the regression completely, since > we get a similar unstable satisfaction error if one of the constrained > members is actually a copy/move special member. I suppose we need to > rearrange things in finish_struct_1 so that check_methods gets called in > a complete class context? I think the way to make that work, if indeed that's desirable, would be to determine those properties lazily instead of at finish_struct time. The patch is OK. > PR c++/108579 > > gcc/cp/ChangeLog: > > * class.cc (check_methods): Test constraints_satisfied_p after > testing copy_fn_p / move_fn_p instead of beforehand. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/concepts-pr108579.C: New test. > --- > gcc/cp/class.cc | 16 ++++++++-------- > gcc/testsuite/g++.dg/cpp2a/concepts-pr108579.C | 14 ++++++++++++++ > 2 files changed, 22 insertions(+), 8 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-pr108579.C > > diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc > index 351de6c5419..d3ce8532d56 100644 > --- a/gcc/cp/class.cc > +++ b/gcc/cp/class.cc > @@ -4822,11 +4822,11 @@ check_methods (tree t) > /* Might be trivial. */; > else if (TREE_CODE (fn) == TEMPLATE_DECL) > /* Templates are never special members. */; > - else if (!constraints_satisfied_p (fn)) > - /* Not eligible. */; > - else if (copy_fn_p (fn)) > + else if (copy_fn_p (fn) > + && constraints_satisfied_p (fn)) > TYPE_HAS_COMPLEX_COPY_CTOR (t) = true; > - else if (move_fn_p (fn)) > + else if (move_fn_p (fn) > + && constraints_satisfied_p (fn)) > TYPE_HAS_COMPLEX_MOVE_CTOR (t) = true; > } > > @@ -4836,11 +4836,11 @@ check_methods (tree t) > /* Might be trivial. */; > else if (TREE_CODE (fn) == TEMPLATE_DECL) > /* Templates are never special members. */; > - else if (!constraints_satisfied_p (fn)) > - /* Not eligible. */; > - else if (copy_fn_p (fn)) > + else if (copy_fn_p (fn) > + && constraints_satisfied_p (fn)) > TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = true; > - else if (move_fn_p (fn)) > + else if (move_fn_p (fn) > + && constraints_satisfied_p (fn)) > TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = true; > } > } > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr108579.C b/gcc/testsuite/g++.dg/cpp2a/concepts-pr108579.C > new file mode 100644 > index 00000000000..bc7d709f889 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr108579.C > @@ -0,0 +1,14 @@ > +// PR c++/108579 > +// { dg-do compile { target c++20 } } > + > +template > +struct A { > + A(double, char); > + A(int) requires requires { A(0.0, 'c'); }; > + A& operator=(int) requires requires { A(1.0, 'd'); }; > +}; > + > +int main() { > + A x(3); > + x = 5; > +}