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 E067C385B53D for ; Fri, 12 May 2023 17:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E067C385B53D 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=1683910966; 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=3k9djXvmj5xi2+B8gldQ/adgTKgybmuQGtyUvSAkSbk=; b=BUHDfYOByXhiyhkQLjddio4WcDwIlIyuTriggrWjhu1eDy3VmWCeJNOesnjKEqEqGlirTX hHCREbe+PNfxPYuXwz0arUblJ/KAgjCkhf3SOsr8KuZzC/qEsxZKym+ZJcVa38p21Gl88P V15F2271IMwWIXnE65O4Rngk+/iTqoQ= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-551-i0Ftz_qSOiSMZ0L7bu9S-g-1; Fri, 12 May 2023 13:02:45 -0400 X-MC-Unique: i0Ftz_qSOiSMZ0L7bu9S-g-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-4f132fae59eso5564929e87.2 for ; Fri, 12 May 2023 10:02:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683910963; x=1686502963; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3k9djXvmj5xi2+B8gldQ/adgTKgybmuQGtyUvSAkSbk=; b=SHN4+RCqHcFDXIlwtJ8hmAblr1PqPTWW/AN6Ib8XTWScLgXnTuxavGg+N6VMgvBlIC kojtc7xyA0T4qIGba+wdZkVwxtH1Ts1gmPUndjwo0LxGsy49YFAbXFxBU6zNf+SOSUay tlc5M683e9xRh2BvgDJFHyxe3mS0OW9avS74OxOTl0anjB3vb0iRlCdixl6ZWVJPZlTk vAwhJbVngHzDY+OaHWWqBTvXVg4lMlaiuStKrqkOVduiGcL+5q4xbC1jHn3WLMxaj9eH 1x8f/ht+9caKHgvO2/OqNx3ihiyBaZzK2JnGQNrrf69RZ2/lCKounoXqezaHNwAN+Kz4 TFWw== X-Gm-Message-State: AC+VfDy1Mas1yJQf75zkrTuZVg+F/qD/lQQPJh8LlstTKhSsiQrFDswJ V9GcgtNddKscZ4pBBT2bNJdccMiBVetTq2kKxFwW6l5ZM/To+rEOVXEdDZoahJMPNVjNhGQuNVg 7ogJvZuglNQeR/HfaZiIrFYK0/iICFBkB+g== X-Received: by 2002:ac2:53ae:0:b0:4f1:44c0:a921 with SMTP id j14-20020ac253ae000000b004f144c0a921mr4494704lfh.55.1683910963531; Fri, 12 May 2023 10:02:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NvlUHiF6p6vj7XL9LJhieL/l7RDdM6vs+aFAeclHpLZO4D4NGNhNxDsochaYzeUWPi7/locgqzDl3plSUxx0= X-Received: by 2002:ac2:53ae:0:b0:4f1:44c0:a921 with SMTP id j14-20020ac253ae000000b004f144c0a921mr4494697lfh.55.1683910963219; Fri, 12 May 2023 10:02:43 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Patrick Palka Date: Fri, 12 May 2023 13:02:32 -0400 Message-ID: Subject: Re: [PATCH 1/2] c++: potentiality of templated memfn call [PR109480] To: Martin Jambor Cc: gcc-patches@gcc.gnu.org, Jason Merrill X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Martin, On Fri, May 12, 2023 at 12:13=E2=80=AFPM Martin Jambor wr= ote: > > 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 tim= e, > > 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 handlin= g > > of the object argument of a non-static member function call is effectiv= ely > > 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 ad= apt > > 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=3Dc++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. > > Thanks, > > Martin >