From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by sourceware.org (Postfix) with ESMTPS id 49AAB38A90AA for ; Sun, 19 Nov 2023 18:37:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49AAB38A90AA Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=protonmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 49AAB38A90AA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.22 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700419044; cv=none; b=qh1rawJUDiF5RMOlKqe/3vcE8PWCXckn7hWmZXfEwpk6tP2UReFZaU/GceQnmczEWlG2UTTB1Bq3p5wlqgNzbDUUIiCm4EZtZDFI9m7rl9CqATvNmhR7ys5kz8rSErOVlb0mfuQQ2XTuK0S/7H/1UJMCza93Esv2mTbt48dPi30= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700419044; c=relaxed/simple; bh=aDRO3nDK4qxAXRzVLzehiSE23PLz7pcoaT25LgB1t8o=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=oMgkryJGRBamx+T4m/b2g8/7S5H83nZ0pKDwcYjdzChlXLL+yRqVoCOnHacgVG3jxPD1k7G0Kp1F9pqU8iiITeuvFOYGTqH9ZkAgPoCqRqmMHojBVEPRgp0itpm1jMXePVhTRdnyUgok033i3GWq2hkiqJ35yE76ClcsxHoqx64= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1700419041; x=1700678241; bh=W9zzJ8OJyBDjrCC/VYTQnmJbG9iXTrPmPKCjD5gBqqg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=YrxavyEu86URDC/UwiK3BQbcgxypy7r0fe46f1RAaEI+kVzwI4pQ8aQNg++0CnuEF 1wlc0SaCqTU6ZiKlX/yHXR2EJHcMi1A8sh5r5qpdSehzuZF4rL0EwnGiQ7bdS6NPDS 4f47C9L3pgcCmwNBW0yYpPaieaVwh8ZLrSKso9NS8ANXV2V0NdpEDeUXR4CSHGN/gF tZkETrCTh7rOSTJroDJI4rFe3SX12+asJZqPpYmCT+VRTIGMVBuKA2TisoUsgZQxEX g25UAd4CIgVEk8FAS4ND32SPcemc5awLeryq4u2TU+AdqT62OhzLWNJhRH+EPxVzUq avVa8o1pDOL6A== Date: Sun, 19 Nov 2023 18:36:58 +0000 To: Jason Merrill From: waffl3x Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH v3 1/2] c++: Initial support for P0847R7 (Deducing This) [PR102609] Message-ID: In-Reply-To: References: Feedback-ID: 14591686:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,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 Sunday, November 19th, 2023 at 9:31 AM, Jason Merrill = wrote: > > > On 11/19/23 08:39, waffl3x wrote: > > > Funny enough I ended up removing the ones I was thinking about, seems > > to always happen when I ask style questions but I'm glad to hear it's > > okay going forward. > > > > I'm having trouble fixing this bug, based on what Gasper said in > > PR102609 I am pretty sure I know what the semantics should be. Since > > the capture is not used in the body of the function, it should be well > > formed to call the function with an unrelated type. > > > I don't think so: https://eel.is/c++draft/expr.prim#lambda.closure-5 > says the type of the xobj parameter must be related. Well, thanks for bringing that to my attention, that makes things easier but I'm kinda disappointed, I almost wanted an excuse to write more code. I wonder why Gasper thought this wasn't the case, perhaps it was a later decision? Okay, I checked, that paragraph is in the original paper, I thought I could just take what one of the paper's authors said for granted but I guess not, I'm not going to make that mistake again. On the other hand, maybe he just misunderstood my question, what can you do. Well regardless, that reduces the things I have left to do by a whole lot. > > I had begun trying to tackle the case that Gasper mentioned and got the > > following ICE. I also have another case that ICEs so I've been thinking > > I don't get to do little changes to fix this. I've been looking at this > > for a few hours now and given we are past the deadline now I figured I > > should see what others think. > > > > int main() > > { > > int x =3D 42; > > auto f1 =3D [x](this auto&& self) {}; > > > > static_cast(decltype(f1)::operator()); > > } > > > This should be rejected when we try to instantiate the op() with int. Yep, absolutely, that is clear now. Just for the record, clang accepts it, but since I can't think of any use cases for this I don't think there's any value in supporting it. > > > As I said, there is also this case that also ICEs in the same region. > > It's making me think that some core assumptions are being violated in > > the code leading up to finish_non_static_data_member. > > > > int main() > > { > > int x =3D 42; > > auto f1 =3D [x](this auto self) {}; > > } > > > Here I think the problem is in build_capture_proxy: > > > /* The proxy variable forwards to the capture field. */ > > object =3D build_fold_indirect_ref (DECL_ARGUMENTS (fn)); > > object =3D finish_non_static_data_member (member, object, NULL_TREE); > > > The call to build_fold_indirect_ref assumes that 'this' is a pointer, > which it is not here. I think you can just make that conditional on it > being a pointer or reference? > > Jason Thanks, I will take a look at that area. I'm having trouble fixing the error for this case, the control flow when the functions are overloaded is much more complex. struct S { void f(this S&) {} void f(this S&, int) void g() { void (*fp)(S&) =3D &f; } }; This seemed to have fixed the non overloaded case, but I'm also not very happy with it, it feels kind of icky. Especially since the expr's location isn't available here, although, it just occurred to me that the expr's location is probably stored in the node. typeck.cc:cp_build_addr_expr_1 ``` case BASELINK: arg =3D BASELINK_FUNCTIONS (arg); if (DECL_XOBJ_MEMBER_FUNC_P ( { error ("You must qualify taking address of xobj member functions"= ); =09 return error_mark_node; } Anyway, I'm quite tired but I'll to finish off the lambda stuff before calling it, then I'll run a bootstrap and tests and if all is well I will submit the patch. I will probably skimp on the changelog and commit message as that's the part I have the hardest time on, especially when I'm tired. Alex ```