Skip to content

Fix typecast in interpreter #3255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions src/goto-programs/interpreter_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
#include <util/string_container.h>

#include <langapi/language_util.h>
#include <util/expr_util.h>

/// Reads a memory address and loads it into the `dest` variable.
/// Marks cell as `READ_BEFORE_WRITTEN` if cell has never been written.
Expand Down Expand Up @@ -345,24 +346,29 @@ void interpretert::evaluate(
}
else if(expr.type().id() == ID_pointer)
{
mp_integer i=0;
if(expr.has_operands() && expr.op0().id()==ID_address_of)
if(expr.has_operands())
{
evaluate(expr.op0(), dest);
return;
}
else if(expr.has_operands() && !to_integer(expr.op0(), i))
{
dest.push_back(i);
return;
const exprt &object = skip_typecast(expr.op0());
if(object.id() == ID_address_of)
{
evaluate(object, dest);
return;
}
else if(const auto i = numeric_cast<mp_integer>(object))
{
dest.push_back(*i);
return;
}
}
// check if expression is constant null pointer without operands
else if(
!expr.has_operands() && !to_integer(to_constant_expr(expr), i) &&
i.is_zero())
else
{
dest.push_back(i);
return;
const auto i = numeric_cast<mp_integer>(expr);
if(i && i->is_zero())
{
dest.push_back(*i);
return;
}
}
}
else if(expr.type().id()==ID_floatbv)
Expand Down