Skip to content

Fix --nondet-volatile bug #5360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions regression/goto-instrument/nondet-volatile-01/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>

void main()
{
int a[2] = {0};

volatile int i = 0;
a[i] = 1;

assert(a[1] == 0); // should fail
}
9 changes: 9 additions & 0 deletions regression/goto-instrument/nondet-volatile-01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
test.c
--nondet-volatile
^EXIT=10$
^SIGNAL=0$
--
--
Check that volatile variables appearing in the lhs of an assignment are
correctly treated as nondet
11 changes: 5 additions & 6 deletions src/goto-instrument/nondet_volatile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static bool is_volatile(const namespacet &ns, const typet &src)
return false;
}

void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr)
static void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr)
{
Forall_operands(it, expr)
nondet_volatile_rhs(symbol_table, *it);
Expand All @@ -52,7 +52,7 @@ void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr)
}
}

void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr)
static void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr)
{
if(expr.id()==ID_if)
{
Expand All @@ -75,9 +75,8 @@ void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr)
}
}

void nondet_volatile(
symbol_tablet &symbol_table,
goto_programt &goto_program)
static void
nondet_volatile(symbol_tablet &symbol_table, goto_programt &goto_program)
{
namespacet ns(symbol_table);

Expand All @@ -88,7 +87,7 @@ void nondet_volatile(
if(instruction.is_assign())
{
nondet_volatile_rhs(symbol_table, to_code_assign(instruction.code).rhs());
nondet_volatile_lhs(symbol_table, to_code_assign(instruction.code).rhs());
nondet_volatile_lhs(symbol_table, to_code_assign(instruction.code).lhs());
}
else if(instruction.is_function_call())
{
Expand Down
4 changes: 0 additions & 4 deletions src/goto-instrument/nondet_volatile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ Author: Daniel Kroening, [email protected]

#include <goto-programs/goto_model.h>

bool is_volatile(
const symbol_tablet &,
const typet &);

void nondet_volatile(goto_modelt &);

#endif // CPROVER_GOTO_INSTRUMENT_NONDET_VOLATILE_H