Skip to content

Commit 284c3aa

Browse files
committed
Note type inconsistencies in solver axioms and avoid simplifying
1 parent 7b3f0c1 commit 284c3aa

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/solvers/strings/string_constraint_generator_main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ array_string_exprt array_poolt::make_char_array_for_char_pointer(
120120
if_expr.cond(),
121121
to_array_type(t.type()).size(),
122122
to_array_type(f.type()).size()));
123+
// BEWARE: this expression is possibly type-inconsistent and must not be
124+
// used for any purposes other than passing it to concretisation
123125
return to_array_string_expr(if_exprt(if_expr.cond(), t, f, array_type));
124126
}
125127
const bool is_constant_array =

src/solvers/strings/string_refinement.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,18 @@ static optionalt<exprt> get_array(
917917
{
918918
const auto eom = messaget::eom;
919919
const exprt &size = arr.length();
920-
exprt arr_val = simplify_expr(super_get(arr), ns);
920+
exprt s = super_get(arr);
921+
while(s.id() == ID_if)
922+
{
923+
const exprt simp_cond = simplify_expr(to_if_expr(s).cond(), ns);
924+
if(simp_cond.is_true())
925+
s = to_if_expr(s).true_case();
926+
else if(simp_cond.is_false())
927+
s = to_if_expr(s).false_case();
928+
else
929+
break;
930+
}
931+
exprt arr_val = simplify_expr(s, ns);
921932
exprt size_val = super_get(size);
922933
size_val = simplify_expr(size_val, ns);
923934
const typet char_type = arr.type().subtype();

0 commit comments

Comments
 (0)