Skip to content

Commit 9b2d8e7

Browse files
committed
Perform type conversion if needed in partial-order read-from
Inconsistent types may arise when the input program uses arrays of non-constant size. An example thereof is contained in SV-COMP: cbmc --unwind 2 --stop-on-fail --32 c/pthread-C-DAC/pthread-numerical-integration_true-unreach-call.i
1 parent 72eebb8 commit 9b2d8e7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/goto-symex/memory_model.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Author: Michael Tautschnig, [email protected]
1111

1212
#include "memory_model.h"
1313

14+
#include <util/arith_tools.h>
15+
#include <util/base_type.h>
16+
#include <util/byte_operators.h>
17+
#include <util/c_types.h>
1418
#include <util/std_expr.h>
1519

1620
memory_model_baset::memory_model_baset(const namespacet &_ns):
@@ -89,9 +93,16 @@ void memory_model_baset::read_from(symex_target_equationt &equation)
8993

9094
// We rely on the fact that there is at least
9195
// one write event that has guard 'true'.
96+
exprt read_value = r->ssa_lhs;
97+
if(!base_type_eq(r->ssa_lhs, r->ssa_rhs, ns))
98+
read_value = byte_extract_exprt(
99+
byte_extract_id(),
100+
r->ssa_lhs,
101+
from_integer(0, index_type()),
102+
w->ssa_lhs.type());
92103
implies_exprt read_from(s,
93104
and_exprt(w->guard,
94-
equal_exprt(r->ssa_lhs, w->ssa_lhs)));
105+
equal_exprt(read_value, w->ssa_lhs)));
95106

96107
// Uses only the write's guard as precondition, read's guard
97108
// follows from rf_some

0 commit comments

Comments
 (0)