Skip to content

Commit c2d7554

Browse files
author
Daniel Kroening
authored
Merge pull request #390 from smowton/clean_vla_size
Clean variable-length array size expressions. Fixes verification-engine-utils#192
2 parents 790f9f6 + edb6908 commit c2d7554

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class VarLengthArrayTrace1 {
2+
3+
public static void main(int unknown, int arg2) {
4+
5+
Container c = new Container(unknown);
6+
if(c.val != 2) return;
7+
int[] arr = new int[c.val];
8+
arr[1] = arg2;
9+
int test = arr[1];
10+
assert(test != 10);
11+
12+
}
13+
14+
}
15+
16+
class Container {
17+
18+
public Container(int v) { val = v; }
19+
int val;
20+
21+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
VarLengthArrayTrace1.class
3+
--trace
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
dynamic_3_array\[1l\]=10
7+
--
8+
^warning: ignoring
9+
assignment removed
10+
irep("(\\"nil\\")")

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ void goto_symext::symex_cpp_new(
478478
{
479479
symbol.type=array_typet();
480480
symbol.type.subtype()=code.type().subtype();
481-
symbol.type.set(ID_size, code.find(ID_size));
481+
exprt size_arg=static_cast<const exprt&>(code.find(ID_size));
482+
clean_expr(size_arg, state, false);
483+
symbol.type.set(ID_size, size_arg);
482484
}
483485
else
484486
symbol.type=code.type().subtype();

0 commit comments

Comments
 (0)