diff --git a/regression/cbmc/void_pointer3/main.c b/regression/cbmc/void_pointer3/main.c new file mode 100644 index 00000000000..1a9ed7c6e16 --- /dev/null +++ b/regression/cbmc/void_pointer3/main.c @@ -0,0 +1,19 @@ +#include + +int main() +{ + // make sure they are NULL objects + void *p=0, *q=0; + // with the object:offset encoding we need to make sure the address arithmetic + // below will only touch the offset part + __CPROVER_assume(sizeof(unsigned char)0, "object size expected to be non-zero"); + typet pointer_sub_type=expr.op0().type().subtype(); + if(pointer_sub_type.id()==ID_empty) + pointer_sub_type=char_type(); + mp_integer element_size=pointer_offset_size(pointer_sub_type, ns); + DATA_INVARIANT(element_size>0, "object size expected to be positive"); offset_arithmetic(bv, element_size, neg_op1); @@ -469,9 +471,11 @@ bvt bv_pointerst::convert_bitvector(const exprt &expr) bvt bv=bv_utils.sub(op0, op1); - mp_integer element_size= - pointer_offset_size(expr.op0().type().subtype(), ns); - DATA_INVARIANT(element_size>0, "object size expected to be non-zero"); + typet pointer_sub_type=expr.op0().type().subtype(); + if(pointer_sub_type.id()==ID_empty) + pointer_sub_type=char_type(); + mp_integer element_size=pointer_offset_size(pointer_sub_type, ns); + DATA_INVARIANT(element_size>0, "object size expected to be positive"); if(element_size!=1) {