Skip to content

Clean variable-length array size expressions. Fixes verification-engine-utils#192 #390

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 2 commits into from
Jan 17, 2017
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.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class VarLengthArrayTrace1 {

public static void main(int unknown, int arg2) {

Container c = new Container(unknown);
if(c.val != 2) return;
int[] arr = new int[c.val];
arr[1] = arg2;
int test = arr[1];
assert(test != 10);

}

}

class Container {

public Container(int v) { val = v; }
int val;

}
10 changes: 10 additions & 0 deletions regression/cbmc-java/VarLengthArrayTrace1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
VarLengthArrayTrace1.class
--trace
^EXIT=10$
^SIGNAL=0$
dynamic_3_array\[1l\]=10
--
^warning: ignoring
assignment removed
irep("(\\"nil\\")")
4 changes: 3 additions & 1 deletion src/goto-symex/symex_builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ void goto_symext::symex_cpp_new(
{
symbol.type=array_typet();
symbol.type.subtype()=code.type().subtype();
symbol.type.set(ID_size, code.find(ID_size));
exprt size_arg=static_cast<const exprt&>(code.find(ID_size));
clean_expr(size_arg, state, false);
symbol.type.set(ID_size, size_arg);
}
else
symbol.type=code.type().subtype();
Expand Down