-
Notifications
You must be signed in to change notification settings - Fork 274
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
69 changes: 69 additions & 0 deletions
69
jbmc/regression/jbmc/NondetArrayPrimitive/NondetArrayPrimitive.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
class NondetArrayPrimitive | ||
{ | ||
void intArray(int[] array) | ||
{ | ||
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; | ||
} | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
jbmc/regression/jbmc/NondetArrayPrimitive/doubleArray.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
jbmc/regression/jbmc/NondetArrayPrimitive/intArrayMulti.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test that checks that?