This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/78383] label as values ICE with C++ lambda
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 17 Nov 2016 12:15:56 +0000
- Subject: [Bug c++/78383] label as values ICE with C++ lambda
- Auto-submitted: auto-generated
- References: <bug-78383-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78383
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code,
| |wrong-code
Status|ASSIGNED |NEW
CC| |jason at gcc dot gnu.org
Component|tree-optimization |c++
Assignee|rguenth at gcc dot gnu.org |unassigned at gcc dot gnu.org
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The ICE is easily fixed but the missing DECL_NONLOCAL causes a miscompilation
into an endless loop because we move the label before the lambda call. The
lambda doesn't seem to be a nested function (which contains DECL_NONLOCAL
handling) so the C++ frontend needs to handle this.
Almost finished testing a patch for the ICE, leaving to C++ FE people to
either reject the testcase or set DECL_NONLOCAL properly.
For reference, the following is the fix for the ICE:
Index: gcc/tree-cfgcleanup.c
===================================================================
--- gcc/tree-cfgcleanup.c (revision 242539)
+++ gcc/tree-cfgcleanup.c (working copy)
@@ -230,6 +230,8 @@ cleanup_control_flow_bb (basic_block bb,
edges which do not go to the right block. For the one
edge which goes to the right block, fix up its flags. */
label = TREE_OPERAND (gimple_goto_dest (stmt), 0);
+ if (DECL_CONTEXT (label) != cfun->decl)
+ return retval;
target_block = label_to_block (label);
for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
{