Skip to content

Commit 8363450

Browse files
Make interpreter handle typecast in pointer expr
The interpreter would fail to interpret expressions of type pointer which contained typecast. This fixes it by following inside the typecast that are encountered.
1 parent d6a0dc7 commit 8363450

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/goto-programs/interpreter_evaluate.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,19 @@ void interpretert::evaluate(
347347
{
348348
if(expr.has_operands())
349349
{
350-
if(expr.op0().id() == ID_address_of)
350+
auto object_ref = std::ref(expr.op0());
351+
while(const auto typecast =
352+
expr_try_dynamic_cast<typecast_exprt>(object_ref.get()))
351353
{
352-
evaluate(expr.op0(), dest);
354+
object_ref = std::ref(typecast->op0());
355+
}
356+
357+
if(object_ref.get().id() == ID_address_of)
358+
{
359+
evaluate(object_ref.get(), dest);
353360
return;
354361
}
355-
if(const auto i = numeric_cast<mp_integer>(expr.op0()))
362+
if(const auto i = numeric_cast<mp_integer>(object_ref))
356363
{
357364
dest.push_back(*i);
358365
return;

0 commit comments

Comments
 (0)