@@ -565,7 +565,7 @@ goto_programt::const_targett goto_program2codet::convert_goto(
565565 else if (!target->guard .is_true ())
566566 return convert_goto_switch (target, upper_bound, dest);
567567 else if (!loop_last_stack.empty ())
568- return convert_goto_break_continue (target, dest);
568+ return convert_goto_break_continue (target, upper_bound, dest);
569569 else
570570 return convert_goto_goto (target, dest);
571571}
@@ -803,7 +803,14 @@ bool goto_program2codet::set_block_end_points(
803803
804804 // ignore dead instructions for the following checks
805805 if (n.dominators .empty ())
806+ {
807+ // simplification may have figured out that a case is unreachable
808+ // this is possibly getting too weird, abort to be safe
809+ if (case_end==it->case_start )
810+ return true ;
811+
806812 continue ;
813+ }
807814
808815 // find the last instruction dominated by the case start
809816 if (n.dominators .find (it->case_start )==n.dominators .end ())
@@ -1107,7 +1114,7 @@ goto_programt::const_targett goto_program2codet::convert_goto_if(
11071114 upper_bound->location_number < end_if->location_number ))
11081115 {
11091116 if (!loop_last_stack.empty ())
1110- return convert_goto_break_continue (target, dest);
1117+ return convert_goto_break_continue (target, upper_bound, dest);
11111118 else
11121119 return convert_goto_goto (target, dest);
11131120 }
@@ -1140,6 +1147,7 @@ goto_programt::const_targett goto_program2codet::convert_goto_if(
11401147
11411148goto_programt::const_targett goto_program2codet::convert_goto_break_continue (
11421149 goto_programt::const_targett target,
1150+ goto_programt::const_targett upper_bound,
11431151 codet &dest)
11441152{
11451153 assert (!loop_last_stack.empty ());
@@ -1149,7 +1157,7 @@ goto_programt::const_targett goto_program2codet::convert_goto_break_continue(
11491157 // 1: ...
11501158 goto_programt::const_targett next=target;
11511159 for (++next;
1152- next!=goto_program.instructions .end ();
1160+ next!=upper_bound && next!= goto_program.instructions .end ();
11531161 ++next)
11541162 {
11551163 cfg_dominatorst::cfgt::entry_mapt::const_iterator i_entry=
0 commit comments