Skip to content

Commit 2311826

Browse files
committed
Skip phi assignment if one of the merged states has an uninitialised object
With level-2 counters incremented on declaration and non-deterministic initialisation upon allocation, the only remaining sources are pointer dereferencing, where uninitialised objects necessarily refer to invalid objects. This is a cleaner implementation of 369f077. Removing only the code introduced in 369f077 would yield a wrong result for regression/cbmc/Local_out_of_scope3.
1 parent 810b590 commit 2311826

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/goto-symex/symex_assign.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,6 @@ void goto_symext::symex_assign_symbol(
215215
guardt &guard,
216216
assignment_typet assignment_type)
217217
{
218-
// do not assign to L1 objects that have gone out of scope --
219-
// pointer dereferencing may yield such objects; parameters do not
220-
// have an L2 entry set up beforehand either, so exempt them from
221-
// this check (all other L1 objects should have seen a declaration)
222-
const symbolt *s;
223-
if(!ns.lookup(lhs.get_object_name(), s) &&
224-
!s->is_parameter &&
225-
!lhs.get_level_1().empty() &&
226-
state.level2.current_count(lhs.get_identifier())==0)
227-
return;
228-
229218
exprt ssa_rhs=rhs;
230219

231220
// put assignment guard into the rhs

src/goto-symex/symex_goto.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -463,17 +463,23 @@ void goto_symext::phi_function(
463463
// 1. Either guard is false, so we can't follow that branch.
464464
// 2. Either identifier is of generation zero, and so hasn't been
465465
// initialized and therefor an invalid target.
466-
if(dest_state.guard.is_false())
467-
rhs=goto_state_rhs;
468-
else if(goto_state.guard.is_false())
469-
rhs=dest_state_rhs;
470-
else if(goto_state.level2_current_count(l1_identifier) == 0)
466+
if(
467+
dest_state.guard.is_false() ||
468+
dest_state.level2.current_count(l1_identifier) == 0)
471469
{
472-
rhs = dest_state_rhs;
470+
if(goto_state.level2_current_count(l1_identifier) == 0)
471+
continue;
472+
473+
rhs = goto_state_rhs;
473474
}
474-
else if(dest_state.level2.current_count(l1_identifier) == 0)
475+
else if(
476+
goto_state.guard.is_false() ||
477+
goto_state.level2_current_count(l1_identifier) == 0)
475478
{
476-
rhs = goto_state_rhs;
479+
if(dest_state.level2.current_count(l1_identifier) == 0)
480+
continue;
481+
482+
rhs = dest_state_rhs;
477483
}
478484
else
479485
{

0 commit comments

Comments
 (0)