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 3B7233858D1E for ; Fri, 20 Oct 2023 02:39:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B7233858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3B7233858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697769599; cv=none; b=N01AXItrokzJM9J1VA6xveqsp0VNTYPHbr2/nE6CFq99HSi+w1MHirRsie5elBz1Qi5TDZ5oUwiGDT5vSubFalx0nwjt8cZTn63IpBXo4VSvXqZ2KhFKbHrxmun4WnINkCi/weHjgt6DzerW0GyMA6AJJgDd6Q4pcx5EEstMP4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697769599; c=relaxed/simple; bh=4L8oyNc8M2ugxyLXU+J1/oDQ7YBwu+QKkHVisxLsrgo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=QKZhaE/0hwSaaDnFaKdHraJsjF8aI/XqFGPVXwbWUslFvnAvJlhDyO/qN4kBrjfQxZ/ZkBNGRA4KfxbQCdpBjV7pEZGPH4E3vm6w0MQA0HvntZdRrQeOkNQUF3Kw1b9uYDT6aIuZcyw4wTrXLoSytE6tpH0CCz3unyE8OKzzq00= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697769596; 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=AVI4DynZYUD7/b3zn8RUEj91G0Im6YJTLO0vRY4A/RY=; b=XwWSaZ366tHoolzEQgcOsLiSatNOJnIzEzVX4x7kUCpHnMTvTzAmgw22bo2ruGYInuorcg w3yD2XAsG0B0m0O1FO6CzdO12U9/QNRJXL5beDnXNpqybe2UEw1ziELONpUwfZQal0goLG C1+yZWEbzli1l/OCA23jfSznkKSMj08= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-3EuahC5qNR27YE5Bbo3d2Q-1; Thu, 19 Oct 2023 22:39:52 -0400 X-MC-Unique: 3EuahC5qNR27YE5Bbo3d2Q-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-66d87503d24so4823266d6.3 for ; Thu, 19 Oct 2023 19:39:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697769591; x=1698374391; 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=AVI4DynZYUD7/b3zn8RUEj91G0Im6YJTLO0vRY4A/RY=; b=AUOtMpXvdy8AgpsCmZsFoBCwCg+G58zvMOnwg4LLC+9dpaJtOBiA3K3mptF4cALQ90 LFMkLnjQwKtkuBCGuDE8OD6PE0HqLWhXwkFvWHRdoQYaQiYrUv7jsT/cwCCdYtxeA4/T hhpBfV3o4q0svGAxp7T7UszMWsEi8enEUg2R33i7/2/Hkam44xmlLUzDXkuwliwuAd9m jt45aoYcquqUGrAEHb+q8O3/44ci+sDXFQdpJXg8TCqNqYxWmNT7wOlVn5Wg1QHKc139 f9b/Jb0YeIed47va6ky1mKrrgONpP7IeKuZmHkj7uWY3Uyqn9fniOvnEtDGY+aWiGhYc 4rHA== X-Gm-Message-State: AOJu0YxsWdhw6FtuFJq+4sZ4X0T5hliq9IfKJoaHcDJrAOHmb8oCoQFm hucrZEEQZrMW+AKtxoP/wbABZ/u+HNTgSgR+U5L/fBeRsjYMHaLS4C+bg8WO+sTXFjyAMG3jxA4 q8i0opfc2Al2KL7TsUFEubaNCDA== X-Received: by 2002:ad4:4ea3:0:b0:66d:4f2a:3fd3 with SMTP id ed3-20020ad44ea3000000b0066d4f2a3fd3mr764547qvb.0.1697769591611; Thu, 19 Oct 2023 19:39:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEm1vY0OUhyC3AaJ8MyjUqUhAQcFPrqbma5znOOCZDQy7Qepc816/R7QfjMxUtkGJnHYt0ZLg== X-Received: by 2002:ad4:4ea3:0:b0:66d:4f2a:3fd3 with SMTP id ed3-20020ad44ea3000000b0066d4f2a3fd3mr764532qvb.0.1697769591157; Thu, 19 Oct 2023 19:39:51 -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 dz16-20020ad45890000000b006263a9e7c63sm325924qvb.104.2023.10.19.19.39.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Oct 2023 19:39:50 -0700 (PDT) Message-ID: <1fdadb6b-e4ca-40c1-bb1c-43a0f42826ba@redhat.com> Date: Thu, 19 Oct 2023 22:39:49 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/2] c++: Initial support for P0847R7 (Deducing This) [PR102609] To: waffl3x Cc: "gcc-patches@gcc.gnu.org" References: <0cc5b21d-4b27-4964-bec3-544c86307c74@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: 7bit 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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 10/19/23 19:35, waffl3x wrote: >> (waffl3x (me)) >> At a glance it seems like all I need to do then is disable the >> PTRMEM_OK_P flag then. > > I'm just now realizing that I'm almost certainly wrong about this. It > still needs PTRMEM_OK_P set if there are any implicit-object member > functions in the overload set. That is, if OFFSET_REF includes that > information... but it doesn't seem like it does? Reading the > information on OFFSET_REF, particularly build_offset_ref, seems to > indicate that OFFSET_REF (at least historically) was only for things > with a pointer to member type. Or things that might end up with pointer-to-member type after overload resolution. >>> An OFFSET_REF (with PTRMEM_OK_P) is used to express that we saw the >>> &A::f syntax, so we could build a pointer to member if it resolves to an >>> implicit-object member function. >>> >>> For an overload set containing only a single static member function, >>> build_offset_ref doesn't bother to build an OFFSET_REF, but returns the >>> BASELINK itself. > > Based on what you've said, I assume that OFFSET_REF handles static > member functions that are overloaded. But as I've said this seems to > contradict the comments I'm reading, so I'm not sure that I'm > understanding you correctly. That's right. For instance, struct A { static void g(); static void g(int); }; void (*p)(int) = &A::g; // cp_build_addr_expr_1 gets an OFFSET_REF >>> I think we need the OFFSET_REF for an explicit-object member function >>> because it expresses that the code satisfies the requirement "If the >>> operand names an explicit object member function, the operand shall be a >>> qualified-id." > > I do agree here, but it does reinforce that OFFSET_REF is no longer > just for members represented by pointer to member type. So that might > be something to take into consideration. An OFFSET_REF that isn't type_unknown_p, agreed. >>> It might simplify things to remove the optimization in build_offset_ref >>> so we get an OFFSET_REF even for a single static member function, and >>> add support for that to cp_build_addr_expr_1. > > I don't think this should be necessary, the "right thing" should just > be done for explicit-object member functions. With all the stuff going > on here that I missed I'm starting to wonder how function overloads > ever worked at all in my patch. On the other hand though, this > optimization probably could be documented better, but I very well might > have missed it even if it were. > > Hell, maybe it needs a greater redesign altogether, it seems strange to > me to bundle overload information in with a construct for a specific > expression. (Assuming that's whats happening of course, I still don't > fully understand it.) It's not like this has rules unique to it for how > overload resolution is decided, right? Initializing a param/variable of > pointer to function type with an overloaded function resolves that with > similar rules, I think? Maybe it is a little different now that I write > it out loud. > > I wasn't going to finish my musings about that, but it made me realize > that it might not actually be correct for address of explicit-object > member functions to be wrapped by OFFSET_REF. I mean surely it's fine > because based on what you've said static member functions are also > wrapped by OFFSET_REF, so it's likely fully implemented, especially > considering things worked before. But now that there are 2 different > varieties of class members that the address of them can be taken, it > might make sense to split things up a bit? Then again, why were static > member functions ever handled the same way? Taking the address of other > static members isn't handled in the same way here is it? Functions are different because of overloading; in general we can't decide what an expression that names a function actually means until we have enough context to decide which function, exactly. So we represent the id-expression largely as lookup+syntax until overload resolution turns it into a specific function. The type_unknown_p check earlier in cp_build_addr_expr_1 is for that case. An id-expression that names a single non-template function (!really_overloaded_fn) is handled somewhat differently, as we don't need to defer everything. But that means various special-case code. Currently build_offset_ref special-cases &A::f for a single static member function, but we can't use the same special case for single explicit object member functions because we need to distinguish between &A::f and &f somehow to check the requirement I quoted above. So it seems to me we'll need to add support for single explicit object member functions in the OFFSET_REF handling in cp_build_addr_expr_1. And I thought if we're doing that, perhaps we want to move the single static handling over there as well, but that's not necessary. Jason