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 982BA3858406 for ; Thu, 3 Nov 2022 18:54:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 982BA3858406 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=1667501686; 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=FuBqdQ7qHHGIX1WF/zU2zykrhWQXpBsetpZU4BII+Qk=; b=D9uWIEjUxQW5m1vPMWFMgwWS3SOpMg7K4L15PKqPIhH38ZgP7GZlH1jSeEBx6NlcLxERV6 wdxA7F+C15vzvaTKo4U9IlQs3iwD8Q3qEJFwxj40qFp0ENpXdoy9M6GL7xCf5BBs8U7nVV NoGim7PK166/IOUYn+Wv1Ri+HbF6r/w= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-41-fD7ZCn5eOfOdFFx-hOIcRA-1; Thu, 03 Nov 2022 14:54:43 -0400 X-MC-Unique: fD7ZCn5eOfOdFFx-hOIcRA-1 Received: by mail-qk1-f200.google.com with SMTP id bm2-20020a05620a198200b006fa6eeee4a9so2688895qkb.14 for ; Thu, 03 Nov 2022 11:54:43 -0700 (PDT) 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=FuBqdQ7qHHGIX1WF/zU2zykrhWQXpBsetpZU4BII+Qk=; b=hhcMDOPawnQNYfUiJRhs87sH77Gug9EKO9nDSrHY/+ss0KBubIBMbDSei3uxaRvT+u mujj2Bq2SobW3rK2B4+zAtHIN8J0rP4bspb+YCuYTnOG8AI1hqXBLP0/mwtgbh5HI6OR eVwwstEDpGmh2ssp43oibUJGDiVJn25fB1OOJ80+9mC5dm4fzzQ5vYgAqbGUrxljHrYX qAo77smXzIrAN1dPdL7CpQiZzg3azBNlNxpud/mwK3tY6Wq2rYsgOg1fVuh5OYbdNLhW 5rRAeXc7GJzf670/GqiieBihcYZzfgyhg8c8QV8EXpILvllTffD0WDQ4dhbgaLUlz0+c EiTg== X-Gm-Message-State: ACrzQf0XSzCmTdd+rrNzjysWj1frf5JtJKu/9khzzoJQbACiWG548Bg7 EwlngBoja9DYl5rnxBlx+L0hgSkF0R/dMIHNCgY1c1OSa/swSa9kSyrmW9R+S3tj9nPD7vgARLs ZH7Du4NqQebZmmNts1A== X-Received: by 2002:a05:620a:15e9:b0:6fa:438b:f19 with SMTP id p9-20020a05620a15e900b006fa438b0f19mr13993778qkm.506.1667501683240; Thu, 03 Nov 2022 11:54:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM511G8xT7cQAvSCrB/V1bTVyT9rVgjjM8v+IGw/JDTddaOJW43I4cxrJ69Pk+OSoi88QoKDyA== X-Received: by 2002:a05:620a:15e9:b0:6fa:438b:f19 with SMTP id p9-20020a05620a15e900b006fa438b0f19mr13993759qkm.506.1667501682941; Thu, 03 Nov 2022 11:54:42 -0700 (PDT) Received: from [192.168.1.101] (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 u1-20020a05620a0c4100b006ec5238eb97sm1288902qki.83.2022.11.03.11.54.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 11:54:42 -0700 (PDT) Message-ID: Date: Thu, 3 Nov 2022 14:54:41 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH] c++: requires-expr substitution and access checking [PR107179] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20221103154530.1442773-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20221103154530.1442773-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=-13.0 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 11/3/22 11:45, Patrick Palka wrote: > Like during satisfaction, we need to check access immediately during > substitution of a requires-expr since the outcome of an access check can > determine the value of the requires-expr. And otherwise, in contexts > where access checking is deferred (such as during substitution into a > base-clause), a failed access check may leak out from the requires-expr > into a non-SFINAE context and cause a hard error (as in the testcase > below). > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > PR c++/107179 > > gcc/cp/ChangeLog: > > * constraint.cc (tsubst_requires_expr): Make sure we're not > deferring access checks. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/concepts-requires31.C: New test. > --- > gcc/cp/constraint.cc | 3 +++ > gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C | 13 +++++++++++++ > 2 files changed, 16 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C > > diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc > index 5e6a3bcf059..f6ef078171a 100644 > --- a/gcc/cp/constraint.cc > +++ b/gcc/cp/constraint.cc > @@ -2252,6 +2252,9 @@ tsubst_requires_expr (tree t, tree args, sat_info info) > { > local_specialization_stack stack (lss_copy); > > + /* We need to check access during the substitution. */ > + deferring_access_check_sentinel acs (dk_no_deferred); > + > /* A requires-expression is an unevaluated context. */ > cp_unevaluated u; > > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C > new file mode 100644 > index 00000000000..9b7e2a34889 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C > @@ -0,0 +1,13 @@ > +// PR c++/107179 > +// { dg-do compile { target c++20 } } > + > +template struct bool_constant { static constexpr bool value = B; }; > + > +template > + struct is_implicitly_default_constructible > + : bool_constant > + { }; > + > +struct X { private: X(); }; > + > +static_assert( !is_implicitly_default_constructible::value );