Skip to content

Commit 7d8be9d

Browse files
authored
Test for Silicon issue #903 (#851)
1 parent a297ae0 commit 7d8be9d

File tree

1 file changed

+30
-0
lines changed
  • src/test/resources/all/issues/silicon

1 file changed

+30
-0
lines changed

Diff for: src/test/resources/all/issues/silicon/0903.vpr

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
field f: Int
5+
6+
predicate Mem(x: Ref)
7+
{
8+
acc(x.f) && 0 <= x.f
9+
}
10+
11+
function recurse(x: Ref, idx: Int): Int
12+
requires acc(Mem(x), wildcard)
13+
requires unfolding acc(Mem(x), wildcard) in 0 <= idx && idx <= x.f
14+
decreases unfolding acc(Mem(x), wildcard) in x.f - idx
15+
{
16+
unfolding acc(Mem(x), wildcard) in idx == x.f ? 42 : recurse(x, idx + 1)
17+
}
18+
19+
method fooUnsound(x: Ref)
20+
requires Mem(x)
21+
ensures Mem(x)
22+
//:: ExpectedOutput(postcondition.violated:assertion.false)
23+
ensures false // succeeds unexpectedly
24+
{
25+
var oldResult: Int := recurse(x, 0)
26+
unfold Mem(x)
27+
x.f := x.f + 1
28+
fold Mem(x)
29+
var newResult: Int := recurse(x, 0) // this call triggers the unsoundness
30+
}

0 commit comments

Comments
 (0)