@@ -264,8 +264,8 @@ optionalt<bvt> bv_pointerst::convert_address_of_rec(const exprt &expr)
264264 UNREACHABLE;
265265
266266 // get size
267- auto size = pointer_offset_size (array_type.element_type (), ns);
268- CHECK_RETURN (size.has_value () && *size >= 0 );
267+ auto size = size_of_expr (array_type.element_type (), ns);
268+ CHECK_RETURN (size.has_value ());
269269
270270 bv = offset_arithmetic (type, bv, *size, index);
271271 CHECK_RETURN (bv.size ()==bits);
@@ -844,6 +844,28 @@ bvt bv_pointerst::offset_arithmetic(
844844 return offset_arithmetic (type, bv, factor, bv_index);
845845}
846846
847+ bvt bv_pointerst::offset_arithmetic (
848+ const pointer_typet &type,
849+ const bvt &bv,
850+ const exprt &factor,
851+ const exprt &index)
852+ {
853+ bvt bv_factor = convert_bv (factor);
854+ bvt bv_index =
855+ convert_bv (typecast_exprt::conditional_cast (index, factor.type ()));
856+
857+ bv_utilst::representationt rep = factor.type ().id () == ID_signedbv
858+ ? bv_utilst::representationt::SIGNED
859+ : bv_utilst::representationt::UNSIGNED;
860+
861+ bv_index = bv_utils.multiplier (bv_index, bv_factor, rep);
862+
863+ const std::size_t offset_bits = get_offset_width (type);
864+ bv_index = bv_utils.extension (bv_index, offset_bits, rep);
865+
866+ return offset_arithmetic (type, bv, 1 , bv_index);
867+ }
868+
847869bvt bv_pointerst::offset_arithmetic (
848870 const pointer_typet &type,
849871 const bvt &bv,
0 commit comments