Skip to content

Commit fc3073c

Browse files
committed
byte_extract lowering of pointers
Bit operations cannot be performed on pointers, thus type cast them to unsigned bitvectors first and then convert back the result.
1 parent e654aa7 commit fc3073c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/solvers/lowering/byte_operators.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ static exprt unpack_rec(
236236
std::move(byte_operands),
237237
array_typet(unsignedbv_typet(8), from_integer(size, size_type())));
238238
}
239+
else if(src.type().id() == ID_pointer)
240+
{
241+
return unpack_rec(
242+
typecast_exprt(
243+
src, unsignedbv_typet(to_pointer_type(src.type()).get_width())),
244+
little_endian,
245+
offset_bytes,
246+
max_bytes,
247+
ns,
248+
unpack_byte_array);
249+
}
239250
else if(src.type().id()!=ID_empty)
240251
{
241252
// a basic type; we turn that into extractbits while considering

unit/solvers/lowering/byte_operators.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ SCENARIO("byte_extract_lowering", "[core][solvers][lowering][byte_extract]")
124124
signedbv_typet(24),
125125
signedbv_typet(128),
126126
// ieee_float_spect::single_precision().to_type(),
127+
// generates the correct value, but remains wrapped in a typecast
127128
// pointer_typet(u64, 64),
128129
vector_typet(u8, size),
129130
vector_typet(u64, size),

0 commit comments

Comments
 (0)