Skip to content

Commit 6844760

Browse files
authored
Merge pull request #1769 from smowton/smowton/fix/nondet-initialize-after-initialize
Java frontend: only run cproverNondetInitialize after all fields are initialized
2 parents 86a34c9 + 5669d9b commit 6844760

File tree

12 files changed

+53
-5
lines changed

12 files changed

+53
-5
lines changed
452 Bytes
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import org.cprover.CProver;
2+
3+
class Test {
4+
5+
int[] arr;
6+
7+
void cproverNondetInitialize() {
8+
CProver.assume(arr != null && arr.length == 1);
9+
// The following access should now be legal:
10+
arr[0] = 100;
11+
}
12+
13+
public static void main(Test nondetInput) {
14+
}
15+
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CORE
2+
Test.class
3+
4+
^VERIFICATION SUCCESSFUL$
5+
174 Bytes
Binary file not shown.
729 Bytes
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import org.cprover.CProver;
2+
3+
class Test {
4+
5+
int[] arr;
6+
7+
void cproverNondetInitialize() {
8+
CProver.assume(arr != null && arr.length == 1);
9+
// The following access should now be legal:
10+
arr[0] = 100;
11+
}
12+
13+
public static void main(Subclass nondetInput) {
14+
// The condition enforced by cproverNondetInitialize should hold
15+
// even though the parameter is a subtype of Test, not directly an
16+
// instance of Test itself.
17+
assert nondetInput.arr.length == 1;
18+
}
19+
20+
}
21+
22+
class Subclass extends Test { }

0 commit comments

Comments
 (0)