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 E8E0F3857827 for ; Fri, 1 Apr 2022 18:08:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E8E0F3857827 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-595-QWcJOe8RO5qjzKESfPTjFA-1; Fri, 01 Apr 2022 14:08:29 -0400 X-MC-Unique: QWcJOe8RO5qjzKESfPTjFA-1 Received: by mail-qv1-f69.google.com with SMTP id x6-20020ad44626000000b0044119c7bf4aso2590910qvv.12 for ; Fri, 01 Apr 2022 11:08:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=GqEVwSTtiF+cf0W3bcx7Ex1xPX2qARRSQ2juN6X86YU=; b=wEK+Sw9GXog/Lg8bWuUaIO0BjVcPDLnO7KhRA/kdZaZ2vCiRXfkDooYGCfK/PCs46V IVKQZnbqWSbEzg1vzWg2hS3oJTepNs8rMYGGY4/JrTj/yJnH/Bp7kMaYqkxOorKqMJOl jKCxn0f4w6nQ6RWpFVjIYsicIGqEmMAxOzOvl0HWYQRSUHWk8YscHuf2RBt65SUbQx0w BNm2vlyysu2DpUCDJRnHLo+CHo+18039o0J9AEwbfjGMB6cWFJFA6ZrGgv/cazZbDg2G 7IGLkOga1CD+dwCD0THWr9Gm5efC6IocYhBqxiJlLqfqaXmmYQojPOrmyZNyeqNfmDe3 F2pg== X-Gm-Message-State: AOAM533qMwellZbSg8ygSeNE2pGxXzVoxDQKGBaJOuiThzBhYDkr5tsF 1W6MTtrxHQDT4DH4v2sR6QKJTtfWOlB1Q33qmKNVn5xl+9biBIHwUHPPbuKDCisAWksipMfi/hX g2ZmcS356PDNyWor82Q== X-Received: by 2002:ac8:6684:0:b0:2e1:b8e6:9a79 with SMTP id d4-20020ac86684000000b002e1b8e69a79mr9295644qtp.279.1648836509128; Fri, 01 Apr 2022 11:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjtq64meLDFtBUI/VwnHnd07dR7IYkThjB44xRQTN83qaBs6Zd3v06ja/q7fedofwq9iTvJg== X-Received: by 2002:ac8:6684:0:b0:2e1:b8e6:9a79 with SMTP id d4-20020ac86684000000b002e1b8e69a79mr9295625qtp.279.1648836508838; Fri, 01 Apr 2022 11:08:28 -0700 (PDT) Received: from [192.168.1.149] (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 p10-20020a05620a132a00b0067f926e36b2sm1569774qkj.91.2022.04.01.11.08.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Apr 2022 11:08:27 -0700 (PDT) Message-ID: <9c638160-ef60-37cc-a601-afafc700aa0e@redhat.com> Date: Fri, 1 Apr 2022 14:08:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] c++: deduction for dependent class type of NTTP [PR105110] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20220330215107.1833323-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20220330215107.1833323-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: 8bit X-Spam-Status: No, score=-12.9 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_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 01 Apr 2022 18:08:32 -0000 On 3/30/22 17:51, Patrick Palka wrote: > Here deduction for the P/A pair V/a spuriously fails with > > types ‘A’ and ‘const A’ have incompatible cv-qualifiers > > because the argument type is const, whereas the parameter type is > non-const. > > Since the type of an NTTP is always cv-unqualified, it seems natural to > ignore cv-qualifiers on the argument type before attempting to unify the > two types. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > PR c++/105110 > > gcc/cp/ChangeLog: > > * pt.cc (unify) : Ignore cv-quals on > on the argument type of an NTTP before deducing from it. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/nontype-class52.C: New test. > --- > gcc/cp/pt.cc | 5 +++-- > gcc/testsuite/g++.dg/cpp2a/nontype-class52.C | 13 +++++++++++++ > 2 files changed, 16 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class52.C > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 1acb5990c5c..cdd75d3b6ac 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -24271,8 +24271,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, > && !(strict & UNIFY_ALLOW_INTEGER) > && TEMPLATE_PARM_LEVEL (parm) <= TMPL_ARGS_DEPTH (targs)) > { > - /* Deduce it from the non-type argument. */ > - tree atype = TREE_TYPE (arg); > + /* Deduce it from the non-type argument. As above, ignore > + top-level quals here too. */ > + tree atype = cv_unqualified (TREE_TYPE (arg)); > RECUR_AND_CHECK_FAILURE (tparms, targs, > tparm, atype, > UNIFY_ALLOW_NONE, explain_p); > diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class52.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class52.C > new file mode 100644 > index 00000000000..56163376afb > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class52.C > @@ -0,0 +1,13 @@ > +// PR c++/105110 > +// { dg-do compile { target c++20 } } > + > +template struct A { }; > + > +template struct B { }; > + > +template V> void f(B); > + > +int main() { > + constexpr A a; > + f(B{}); > +}