[Bug c++/78383] label as values ICE with C++ lambda

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 17 12:40:00 GMT 2016


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)); )
        {


More information about the Gcc-bugs mailing list