From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6EE4F3889804; Mon, 10 Jan 2022 19:50:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EE4F3889804 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103912] ICE in a consteval function which returns a lambda which takes a "non-POD" argument and the consteval has other code Date: Mon, 10 Jan 2022 19:50: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: 11.2.1 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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, 10 Jan 2022 19:50:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103912 --- Comment #5 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:54fa7daefe35cacf4a933947d1802318da193c01 commit r12-6423-g54fa7daefe35cacf4a933947d1802318da193c01 Author: Jakub Jelinek Date: Mon Jan 10 20:49:11 2022 +0100 c++: Ensure some more that immediate functions aren't gimplified [PR103= 912] Immediate functions should never be emitted into assembly, the FE doesn= 't genericize them and does various things to ensure they aren't gimplifie= d. But the following testcase ICEs anyway due to that, because the constev= al function returns a lambda, and operator() of the lambda has decl_function_context of the consteval function. cgraphunit.c then does: /* Preserve a functions function context node. It will later be needed to output debug info. */ if (tree fn =3D decl_function_context (decl)) { cgraph_node *origin_node =3D cgraph_node::get_create = (fn); enqueue_node (origin_node); } which enqueues the immediate function and then tries to gimplify it, which results in ICE because it hasn't been genericized. When I try similar testcase with constexpr instead of consteval and static constinit auto instead of auto in main, what happens is that the functions are gimplified, later ipa.c discovers they aren't reachab= le and sets body_removed to true for them (and clears other flags) and we = end up with a debug info which has the foo and bar functions without DW_AT_low_pc and other code specific attributes, just stuff from its BL= OCK structure and in there the lambda with DW_AT_low_pc etc. The following patch attempts to emulate that behavior early, so that cg= raph doesn't try to gimplify those and pretends they were already gimplified and found unused and optimized away. 2022-01-10 Jakub Jelinek PR c++/103912 * semantics.c (expand_or_defer_fn): For immediate functions, set node->body_removed to true and clear analyzed, definition and force_output. * decl2.c (c_parse_final_cleanups): Ignore immediate functions = for expand_or_defer_fn. * g++.dg/cpp2a/consteval26.C: New test.=