Skip to content

Loop-less initialization of primitive arrays #3649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
class NondetArrayPrimitive
{
void intArray(int[] array)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test for non-primitive arrays too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And byte, char, short, long, double...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests for all primitive types.
Not for non-primitive types as this PR doesn't change behaviour for those.

Copy link
Member

@peterschrammel peterschrammel Jan 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR doesn't change behaviour for those.

Is there a test that checks that?

{
if (array != null && array.length > 1500 && array[1500] == 42) {
assert false;
}
}

void floatArray(float[] array)
{
if (array != null && array.length > 1500 && array[1500] == 42.0) {
assert false;
}
}

void charArray(char[] array)
{
if (array != null && array.length > 1500 && array[1500] == 'f') {
assert false;
}
}

void doubleArray(double[] array)
{
if (array != null && array.length > 1500 && array[1500] == 42.0) {
assert false;
}
}

void longArray(long[] array)
{
if (array != null && array.length > 1500 && array[1500] == 42) {
assert false;
}
}

void shortArray(short[] array)
{
if (array != null && array.length > 1500 && array[1500] == 42) {
assert false;
}
}

void byteArray(byte[] array)
{
if (array != null && array.length > 1500 && array[1500] == 42) {
assert false;
}
}

void boolArray(boolean[] array)
{
if (array != null && array.length > 1500 && array[1500] == true) {
assert false;
}
}

void intArrayMulti(int[][] array)
{
if (array != null &&
array.length > 2 &&
array[2].length > 50 &&
array[2][50] == 42) {
assert false;
}
}

}
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/boolArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.boolArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 55 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/byteArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.byteArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 48 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/charArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.charArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 20 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/doubleArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.doubleArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 27 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/floatArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.floatArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 13 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/intArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.intArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 6 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/intArrayMulti.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.intArrayMulti --max-nondet-array-length 51 --unwind 4
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 65 assertion.*: FAILURE
--
^warning: ignoring
--
Check inner most array of multi-dimensional array is reachable independently of
--unwind value.
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/longArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.longArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 34 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
12 changes: 12 additions & 0 deletions jbmc/regression/jbmc/NondetArrayPrimitive/shortArray.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
NondetArrayPrimitive.class
--function NondetArrayPrimitive.shortArray --max-nondet-array-length 2000 --unwind 1
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
line 41 assertion.*: FAILURE
--
Unwinding loop __CPROVER__start.0 iteration 2
^warning: ignoring
--
Check no unwind needed to reach non-primitive array cell
2 changes: 1 addition & 1 deletion jbmc/regression/jbmc/json_trace3/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Test.class
activate-multi-line-match
EXIT=10
SIGNAL=0
"lhs": "dynamic_2_array\[1L?\]",\n *"mode": "java",\n *"sourceLocation": \{\n *"bytecodeIndex": "18",\n *"file": "Test\.java",\n *"function": "java::Test\.main:\(\[J\)V",\n *"line": "8"\n *\},\n *"stepType": "assignment",\n *"thread": 0,\n *"value": \{\n *"binary": "0000000000000000000000000000000000000000000000000000000000000001",\n *"data": "1L",\n *"name": "integer",\n *"type": "long",\n *"width": 64
"lhs": "dynamic_object3\[1L?\]",\n *"mode": "java",\n *"sourceLocation": \{\n *"bytecodeIndex": "18",\n *"file": "Test\.java",\n *"function": "java::Test\.main:\(\[J\)V",\n *"line": "8"\n *\},\n *"stepType": "assignment",\n *"thread": 0,\n *"value": \{\n *"binary": "0000000000000000000000000000000000000000000000000000000000000001",\n *"data": "1L",\n *"name": "integer",\n *"type": "long",\n *"width": 64
--
"name": "unknown"
^warning: ignoring
Loading