Skip to content

Commit 2f38d73

Browse files
committed
Disable string indices assertion
This checked that no universally-quantified expression referred to the same string with two different indices, but this is definitely possible (and always has been, e.g. the StartsWith regression test asks for s.startsWtih(s, 1), which essentially asks if s is its own prefix, and produces the expression "forall x, s[x] == s[x+1]". The previous commit's improvement to pointer tracking means symex now exposes that situation more directly, but it would always have happened in reality, just not getting caught by this assertion.
1 parent 697e720 commit 2f38d73

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/solvers/refinement/string_refinement.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,13 @@ static bool is_valid_string_constraint(
21522152
{
21532153
// Condition 1: All indices of the same string must be the of the same form
21542154
const exprt rep=pair.second.back();
2155+
2156+
// This test is disabled because Java like "s.startsWith(s, 1)" produces
2157+
// a constraint like "forall x, s[x] == s[x+1]", which does not meet this
2158+
// constraint as s is indexed with both 'x' and 'x+1' under the same
2159+
// universal quantifier. We should either indirect to avoid the double
2160+
// reference, or establish that this conditon wasn't needed to begin with.
2161+
/*
21552162
for(size_t j=0; j<pair.second.size()-1; j++)
21562163
{
21572164
const exprt i=pair.second[j];
@@ -2164,6 +2171,7 @@ static bool is_valid_string_constraint(
21642171
return false;
21652172
}
21662173
}
2174+
*/
21672175

21682176
// Condition 2: f must be linear in the quantified variable
21692177
if(!is_linear_arithmetic_expr(rep, constraint.univ_var))

0 commit comments

Comments
 (0)