Skip to content

Commit d63d2c7

Browse files
author
Daniel Kroening
authored
Merge pull request #1116 from tautschnig/fix-1115
Do not assign to objects that have gone out of scope
2 parents 16eb98c + 369f077 commit d63d2c7

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
unsigned int *GLOBAL_POINTER[1];
2+
3+
int index;
4+
5+
void f(void)
6+
{
7+
unsigned int actual=0u;
8+
GLOBAL_POINTER[0] = &actual;
9+
10+
if(index==0)
11+
*GLOBAL_POINTER[index] = 1u;
12+
else
13+
actual = 2u;
14+
15+
__CPROVER_assume(1u == actual);
16+
}
17+
18+
void main(void)
19+
{
20+
index=nondet_int();
21+
f();
22+
f();
23+
__CPROVER_assert(0==1, "");
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring

src/goto-symex/symex_assign.cpp

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

214225
// put assignment guard into the rhs

0 commit comments

Comments
 (0)