Skip to content

Commit 0879ad0

Browse files
committed
Add case for byte-extracting arrays
from offset 0, i.e. the whole array should be the result.
1 parent ddf72d1 commit 0879ad0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: src/util/pointer_offset_size.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,17 @@ optionalt<exprt> get_subexpression_at_offset(
632632
return typecast_exprt(expr, target_type_raw);
633633
}
634634

635+
if(
636+
offset_bytes == 0 && expr.type().id() == ID_pointer &&
637+
target_type_raw.id() == ID_array)
638+
{
639+
// subexpression at offset zero is the whole thing even for arrays
640+
return byte_extract_exprt{byte_extract_id(),
641+
expr,
642+
from_integer(offset_bytes, index_type()),
643+
target_type_raw};
644+
}
645+
635646
const typet &source_type = ns.follow(expr.type());
636647
const auto target_size_bits = pointer_offset_bits(target_type_raw, ns);
637648
if(!target_size_bits.has_value())

0 commit comments

Comments
 (0)