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 0FF50385B508 for ; Fri, 12 May 2023 17:13:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FF50385B508 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=1683911605; 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=N2agrlQsbFqTYBzTHnqLN4a/HpuKpOS0QEQuWmBAfUM=; b=LWWi2YU8/9Do/HL6NrW1wcR1qcx4bTh4h57e2D6tFmeGyzgtVwSWNzz5jvUfwN4/cyRkNv mo0+mgf5unpt3vLw2DXGayTNtxB+L/Q2W6xfSafygSRoNMbr8VFQwH2x9HAOjNLr2l0PTA 4rKktn5zpix/U5FFrBjZ6nkokadnqGE= 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_256_GCM_SHA384) id us-mta-658-KA3ZGW8mO9C8dJartryU8A-1; Fri, 12 May 2023 13:13:24 -0400 X-MC-Unique: KA3ZGW8mO9C8dJartryU8A-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-758ae5c9494so476660685a.3 for ; Fri, 12 May 2023 10:13:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683911604; x=1686503604; 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=N2agrlQsbFqTYBzTHnqLN4a/HpuKpOS0QEQuWmBAfUM=; b=U8kcHZWPNPbP/67wDHQp/IUNydjyGIHttXf50jPy9xR5IM6u3ZoSe6RUbAS4QFes1K //UqqrX20ahtSGi7ojCi0Gbacgh4g2Xm+6eX9T/WcFHl7wGfIoGvNOl13ssZ6ZnQhXV4 lCHfqWkNBzWCfFkroC9lFs6HZWepcQYdHyy9of5uZYwqRSweK10ddXFaD381++gtlOQ7 ORWWkI1qJrnhzg6fLgnUORYz7bfEXg84EvtnfhzUpAi2goowB50GNJCaCKvWlw5/kHt/ uqFgjkTWUjGiqQYwyFMwZNxebCsfIQ36RtU01CFXZK+oWhREQ35yqYyKQnkQJrkIy05J CfNg== X-Gm-Message-State: AC+VfDxzwyDprZlxk3WY4QQ1pxot71zaJNichU5dXgf3NRql6Dr3CiMM D1YclyEclir+TTsNAKVJ0rvmzVQ8PBf8xVy5ykqh6HBiCNHuOvfah4royPphBfvpn147kXxczxM uCm+dcdUlBvSPVrHLMg== X-Received: by 2002:a05:622a:2d4:b0:3f3:8b74:dee1 with SMTP id a20-20020a05622a02d400b003f38b74dee1mr30791781qtx.43.1683911603778; Fri, 12 May 2023 10:13:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6gmhNI0zpnecGdbBXiHcGkfhx/q5sHXa4VdmoWB4BxUmzEi3RaiJmQ+zaIVY2po2JTdDDkXA== X-Received: by 2002:a05:622a:2d4:b0:3f3:8b74:dee1 with SMTP id a20-20020a05622a02d400b003f38b74dee1mr30791746qtx.43.1683911603472; Fri, 12 May 2023 10:13:23 -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 h28-20020a05620a10bc00b00759169d0316sm926116qkk.40.2023.05.12.10.13.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 May 2023 10:13:22 -0700 (PDT) Message-ID: <1e148389-a5b1-bb4e-858d-4bd8bb6928f6@redhat.com> Date: Fri, 12 May 2023 13:13:21 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH 1/2] c++: potentiality of templated memfn call [PR109480] To: Patrick Palka , Martin Jambor Cc: gcc-patches@gcc.gnu.org References: <20230501195902.1915703-1-ppalka@redhat.com> <6da23365-02cd-8ac1-2fdc-91b284af6a68@redhat.com> <2aea65a6-eef7-d171-8790-bbb5b9c45d8a@idea> <3744435a-11ea-f9bf-c8de-b040e98b3c0b@idea> <8dacd562-3441-872f-ab4f-20015694eb8f@redhat.com> From: Jason Merrill In-Reply-To: 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=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_ASCII_DIVIDERS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 5/12/23 13:02, Patrick Palka wrote: > Hi Martin, > > On Fri, May 12, 2023 at 12:13 PM Martin Jambor wrote: >> >> Hello Patrick, >> >> On Wed, May 03 2023, Patrick Palka via Gcc-patches wrote: >>> >> [...] >>> >>> Subject: [PATCH] c++: potentiality of templated memfn call [PR109480] >>> >>> Here we're incorrectly deeming the templated call a.g() inside b's >>> initializer as potentially constant, despite g being non-constexpr, >>> which leads to us wastefully instantiating the initializer ahead of time, >>> which incidentally tiggers a bug in access checking deferral (to be >>> fixed by the subsequent patch). >>> >>> This patch fixes this by calling get_fns earlier during CALL_EXPR >>> potentiality checking so that we're able to extract a FUNCTION_DECL out >>> of a templated member function call (whose overall is typically a >>> COMPONENT_REF) and to the usual checking if the called function is >>> constexpr etc. >>> >>> In passing, I noticed potential_constant_expression_1's special handling >>> of the object argument of a non-static member function call is effectively >>> the same as the generic argument handling a few lines later. So this >>> patch just gets rid of this special handling; otherwise we'd have to adapt >>> it to handle templated versions of such calls. >>> >>> PR c++/109480 >>> >>> gcc/cp/ChangeLog: >>> >>> * constexpr.cc (potential_constant_expression_1) : >>> Reorganize to call get_fns sooner. Remove special handling of >>> the object argument of a non-static member function call. Remove >>> dead store to 'fun'. >>> >> >> This patch makes g++ no longer accept the following, complaining that >> get_subsys is non-constexpr (with just -std=c++17 -S), which is of >> course auto-reduced from a much larger source file from Ceph: >> >> ----------------------------------- 8< ----------------------------------- >> struct { >> void get_subsys(); >> } PriorSet_dpp; >> struct PriorSet { >> template PriorSet(); >> }; >> template PriorSet::PriorSet() { >> [](auto cctX) { cctX.template should_gather; }; >> } >> ----------------------------------- 8< ----------------------------------- >> >> I assume that is intentional and am actually somewhat surprised it was >> accepted before, but can you please confirm? > > Yes, this seems correct/intentional to me-- no instantiation of the > template would be valid because it's trying to use a non-constant > expression (which we now correctly identify as such) as a template > argument, so this snippet is IFNDR. > > I don't think we have testsuite coverage for this QoI diagnostic, I'll add one. Incidentally, I wonder about trying to make IFNDR diags in general permerrors or default-error pedwarns, but that doesn't need to happen now. Jason