Skip to content

Enable and use the automatic limit for array-as-uninterpreted-function (duplicated, fixes 6130) #6194

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 6 commits into from
Jul 9, 2021
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
8 changes: 3 additions & 5 deletions src/solvers/flattening/boolbv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,14 +539,12 @@ bool boolbvt::is_unbounded_array(const typet &type) const
if(unbounded_array==unbounded_arrayt::U_ALL)
return true;

const exprt &size=to_array_type(type).size();

const auto s = numeric_cast<mp_integer>(size);
if(!s.has_value())
const std::size_t size = boolbv_width(type);
if(size == 0)
return true;

if(unbounded_array==unbounded_arrayt::U_AUTO)
if(*s > MAX_FLATTENED_ARRAY_SIZE)
if(size > MAX_FLATTENED_ARRAY_SIZE)
return true;

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/flattening/boolbv.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class boolbvt:public arrayst
message_handlert &message_handler,
bool get_array_constraints = false)
: arrayst(_ns, _prop, message_handler, get_array_constraints),
unbounded_array(unbounded_arrayt::U_NONE),
unbounded_array(unbounded_arrayt::U_AUTO),
bv_width(_ns),
bv_utils(_prop),
functions(*this),
Expand Down
8 changes: 4 additions & 4 deletions src/solvers/flattening/boolbv_width.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Author: Daniel Kroening, [email protected]

#include <util/arith_tools.h>
#include <util/c_types.h>
#include <util/exception_utils.h>
#include <util/invariant.h>
#include <util/namespace.h>
#include <util/std_types.h>
Expand Down Expand Up @@ -138,7 +137,6 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const
mp_integer total = *array_size * sub_width;
if(total>(1<<30)) // realistic limit
throw analysis_exceptiont("array too large for flattening");

if(total < 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This case does not seem to be handled any more. Maybe it could become an invariant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some checking and this error handling should be left in since it can trigger an exception if not handled. I've pushed a fix here.

entry.total_width = 0;
else
Expand All @@ -155,8 +153,10 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const
mp_integer total = vector_size * sub_width;
if(total > (1 << 30)) // realistic limit
throw analysis_exceptiont("vector too large for flattening");

entry.total_width = numeric_cast_v<std::size_t>(vector_size * sub_width);
if(total < 0)
entry.total_width = 0;
else
entry.total_width = numeric_cast_v<std::size_t>(vector_size * sub_width);
}
else if(type_id==ID_complex)
{
Expand Down