Skip to content

Skip simple nondet initialization for arrays of bool #3827

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 1 commit into from
Jan 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ void byteArray(byte[] array)
}
}

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

void intArrayMulti(int[][] array)
{
if (array != null &&
Expand Down
12 changes: 0 additions & 12 deletions jbmc/regression/jbmc/NondetArrayPrimitive/boolArray.desc

This file was deleted.

5 changes: 4 additions & 1 deletion jbmc/src/java_bytecode/java_object_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ void java_object_factoryt::gen_nondet_array_init(
init_array_expr =
typecast_exprt(init_array_expr, pointer_type(element_type));

if(element_type.id() == ID_pointer)
if(element_type.id() == ID_pointer || element_type.id() == ID_c_bool)
{
// For arrays of non-primitive types, nondeterministically initialize each
// element of the array
Expand All @@ -1441,6 +1441,9 @@ void java_object_factoryt::gen_nondet_array_init(
else
{
// Arrays of primitive types can be initialized with a single instruction
// We don't do this for arrays of Booleans, because Bools are represented
Copy link
Contributor

Choose a reason for hiding this comment

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

These are bools not Booleans (i.e. we're talking about the primitive type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, I wanted to sound smart by correctly capitalising Boolean, but then of course we can confuse it with Boolean objects. Good catch. Since this is blocking TG, I will leave it as it is and do a PR on top of that to correct the typo.

// as bytes, so each cell must be initialized in a particular way (see
// gen_nondet_init).
array_primitive_init_code(
assignments,
init_array_expr,
Expand Down