Closed
Description
This program is verified by CBMC
class incr
{
int[] nums=new int[]{1,2,3};
void f(int n)
{
if(n==0)
assert(nums[n++]==2);
}
public static void main(String[] args)
{
new incr().f(0);
}
}
as
[java::incr.f:(I)V.assertion.1] assertion at file incr.java line 7 function java::incr.f:(I)V bytecode_index 13: SUCCESS
but java -ea incr
correctly fails
Exception in thread "main" java.lang.AssertionError
at incr.f(incr.java:7)
at incr.main(incr.java:13)
the problem is that the array access index in the GOTO program is incremented before the access is done