From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by sourceware.org (Postfix) with ESMTPS id EF5993858D20 for ; Fri, 24 Nov 2023 06:49:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF5993858D20 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 EF5993858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700808600; cv=none; b=Ego5RwxuNPQMFP2QSY7SVcP3JLGBoWALDHGpHhS6UP32In65ScFL08Xwy1YGvB+1Qv6ZnXGsT2j0+J7Q3ddYKa70UcwuaXIuyY5fMuvDcX4ScsRU8FC+8ftuj0J94P02it9g09d1wbKegPPEMK3C2qd5IZ/sHQ0kjcs8smsmaCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700808600; c=relaxed/simple; bh=iZHC6D7c6XwAwUFP4KRhtZ2NsKpaTAvy6UWU3o4IPjw=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=ev3NyzsPJrnJsb3LZ0xBVZQdgH60UT9Qx1ZfJicX5aG/DKhc40PfNU/8sEqXPp+i10MQEXG5rZpWv5+trAhR0uLKUfeI2dLY9Dk3LaRvChtO0zhlixCBt8r5quS9w1hJacMlOmzjly+WZ608b8fWni2bjx075PYZYHrZNztecVU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1700808595; x=1701067795; bh=APYbGvegqPWm0UBtWISV6p/7LVfjymfLfSyeU62czCs=; 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=t8sPiR9+IlT9WfOqHITQSPmi1XQN0kSyXprUpKRv2AkHoTWJdYpYqwTchRxK8DoM5 +DpeNNzzFUmRcqN/KkfcZXOj/vsEWm3h3Ww4UYD5jFuDtOBoHJfy9CCwTZkrxjDeUp jLsFv/nDnOs9chGnOmDeAJIWpfObNe1be+5sHhzXp0NUWw0BF/lksCJdzNOVUMPEw9 b1hYfO0o+/+elvPSLn2YM9juyNZdxpZvQCTbWjMaZ7MNuDOMbAMoUKR7Ht57hyok+B 0jMEDkpdYJYKcdV3466cUzd7fTYIMfiSEmD7Ihdi5ulpv4ODFN83aGTAPtmjSWltDm h2rs0I1encJ4w== Date: Fri, 24 Nov 2023 06:49:46 +0000 To: waffl3x From: waffl3x Cc: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH v5 1/1] c++: Initial support for P0847R7 (Deducing This) [PR102609] Message-ID: In-Reply-To: References: <9890a007-755e-41e2-bc33-37ebf0755435@redhat.com> <1MdaTybBd_o4uw-Gb23fYyd5GNz7qFqoSe_f5h90LY_BdzM2ge2qPSyCuiCLYoYcZSjmVv13fw1LmjQC_M2L8raS1fydY5pEJ_vwvv5Z-0k=@protonmail.com> <9OlK_2c3Punfm3w-wEHqyHGyKGG8Gr_K0BUnDOuC9Aazur4mWlAM5WuL1Ea0AMLvFLl6LKFVTs813yY0zA7m0_ji_R9qhE52G7MZXrVPfZE=@protonmail.com> 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=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TO_EQ_FM_DIRECT_MX,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: > and this in tsubst_lambda_expr that assumes iobj: >=20 > /* Fix the type of 'this'. */ > fntype =3D build_memfn_type (fntype, type, > type_memfn_quals (fntype), > type_memfn_rqual (fntype)); Unfortunately, putting a condition on this had some unforeseen consequences. I've been working on this about 8 hours today and I'm a little defeated after discovering this. commit 39ade88fa1632c659c5c4ed065fa2b62d16a8670 Author: Jason Merrill Date: Tue Jan 24 15:29:35 2023 -0500 c++: static lambda in template [PR108526] =20 tsubst_lambda_expr uses build_memfn_type to build a METHOD_TYPE for the= new lamba op(). This is not what we want for a C++23 static op(), but sinc= e we also use that METHOD_TYPE to communicate the closure type down to tsubst_function_decl, let's wait and turn it back at that point. =20 PR c++/108526 =20 gcc/cp/ChangeLog: =20 gcc/cp/ChangeLog: =20 * pt.cc (tsubst_function_decl): Handle static lambda. =20 gcc/testsuite/ChangeLog: =20 * g++.dg/cpp23/static-operator-call5.C: New test. diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 2a4d03c5e47..51fc246ed71 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -14306,6 +14306,11 @@ tsubst_function_decl (tree t, tree args, tsubst_fl= ags_t complain, tree ctx =3D closure ? closure : DECL_CONTEXT (t); bool member =3D ctx && TYPE_P (ctx); =20 + /* If this is a static lambda, remove the 'this' pointer added in + tsubst_lambda_expr now that we know the closure type. */ + if (lambda_fntype && DECL_STATIC_FUNCTION_P (t)) + lambda_fntype =3D static_fn_type (lambda_fntype); + I discovered this when I decided to try a static lambda to see if that would help me narrow down my current problem. I was shocked to find out it exhibited the exact same ICE I was trying to fix. So I was going to go undo my changes one by one to see what it was, thankfully this was the first one I tried, I undid the condition I put on it, and the crash was gone. Anyway, this has been my whole day so far, I am going to have to look deeper to decide how exactly I fix this because I don't think this hack that is in place at the moment is the right way to do it. The first idea that comes to mind is modifying the decl_context of the call operator, but I'm really not sure. I'm just going to take a break, eat some pizza, and come back to this hopefully less defeated. Alex