Skip to content

goto-symex: nil array size must not have a type added #5657

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
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/goto-symex/goto_symex_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ goto_symex_statet::rename(exprt expr, const namespacet &ns)
as_const(address_of_expr).object().type();
return renamedt<exprt, level>{std::move(expr)};
}
else if(expr.is_nil())
{
return renamedt<exprt, level>{std::move(expr)};
}
else
{
rename<level>(expr.type(), irep_idt(), ns);
Expand Down
4 changes: 4 additions & 0 deletions src/goto-symex/renaming_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ bool check_renaming(const exprt &expr)
if(to_ssa_expr(expr).get_original_expr().type() != type)
return true;
}
else if(expr.id() == ID_nil)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that still needed after the change in goto_symex_state.cpp?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the sanity check (when using --validate-ssa-equation) - hopefully it never fails...

return expr != nil_exprt{};
}
else
{
forall_operands(it, expr)
Expand Down
13 changes: 13 additions & 0 deletions src/util/std_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ Author: Daniel Kroening, [email protected]
#include "std_expr.h"
#include "string2int.h"

void array_typet::check(const typet &type, const validation_modet vm)
{
PRECONDITION(type.id() == ID_array);
const array_typet &array_type = static_cast<const array_typet &>(type);
if(array_type.size().is_nil())
{
DATA_CHECK(
vm,
array_type.size() == nil_exprt{},
"nil array size must be exactly nil");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message in that check could be clearer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the updated message?

}

std::size_t fixedbv_typet::get_integer_bits() const
{
const irep_idt integer_bits=get(ID_integer_bits);
Expand Down
4 changes: 4 additions & 0 deletions src/util/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,10 @@ class array_typet:public type_with_subtypet
{
return size().is_nil();
}

static void check(
const typet &type,
const validation_modet vm = validation_modet::INVARIANT);
};

/// Check whether a reference to a typet is a \ref array_typet.
Expand Down
4 changes: 4 additions & 0 deletions src/util/validate_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ void call_on_type(const typet &type, Args &&... args)
{
CALL_ON_TYPE(c_bool_typet);
}
else if(type.id() == ID_array)
{
CALL_ON_TYPE(array_typet);
}
else
{
#ifdef REPORT_UNIMPLEMENTED_TYPE_CHECKS
Expand Down