From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8F1963858002; Mon, 29 Mar 2021 12:37:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F1963858002 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99790] [8/9/10/11 Regression] internal compiler error: in expand_expr_real_2 since r7-3811 Date: Mon, 29 Mar 2021 12:37:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2021 12:37:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99790 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- Even more reduced: struct A; struct B { void (*fn) (A *); }; template int foo (const T &); struct A { int a; static constexpr B b{[] (A *n) { n->*&A::a =3D 2; }}; }; int a =3D foo (A::b); The problem seems to be that the lambda is genericized from finish_lambda_function -> finish_function before the A class is finalized, = so case PTRMEM_CST: /* By the time we get here we're handing off to the back end, so we d= on't need or want to preserve PTRMEM_CST anymore. */ *stmt_p =3D cplus_expand_constant (stmt); doesn't do anything. If PTRMEM_CSTs are the only thing, one possible fix could be --- gcc/cp/cp-gimplify.c.jj 2021-03-20 17:01:59.791040946 +0100 +++ gcc/cp/cp-gimplify.c 2021-03-29 14:27:37.532223156 +0200 @@ -660,6 +660,14 @@ cp_gimplify_expr (tree *expr_p, gimple_s ret =3D GS_UNHANDLED; break; + case PTRMEM_CST: + *expr_p =3D cplus_expand_constant (*expr_p); + if (TREE_CODE (*expr_p) =3D=3D PTRMEM_CST) + ret =3D GS_ERROR; + else + ret =3D GS_OK; + break; + case RETURN_EXPR: if (TREE_OPERAND (*expr_p, 0) && (TREE_CODE (TREE_OPERAND (*expr_p, 0)) =3D=3D INIT_EXPR i.e. handle PTRMEM_CSTs not just during genericization, but also during gimplification where because we are unit at a time the classes should be be= tter complete already.=