-
Notifications
You must be signed in to change notification settings - Fork 277
Conversion of pointer_object_exprt
and pointer_offset_exprt
for new SMT backend
#6815
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
Conversion of pointer_object_exprt
and pointer_offset_exprt
for new SMT backend
#6815
Conversation
{ | ||
// Prelude similar to the one used for address-of expression conversion. | ||
|
||
// The config lines are necessary to ensure that pointer width in configured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in -> is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this still needs fixing.
The SAT back end can produce a counter example for the following input. Whereas the SMT back end in your branch cannot -
|
4a49085
to
0685591
Compare
pointer_object_exprt
for new SMT backendpointer_object_exprt
and pointer_offset_exprt
for new SMT backend
0685591
to
0e33060
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6815 +/- ##
===========================================
+ Coverage 77.03% 77.04% +0.01%
===========================================
Files 1594 1594
Lines 185011 185276 +265
===========================================
+ Hits 142514 142748 +234
- Misses 42497 42528 +31
Continue to review full report at Codecov.
|
smt_bit_vector_theoryt::extract(offset_bits - 1, 0)(converted_expr); | ||
if(pointer_width > offset_bits) | ||
{ | ||
return smt_bit_vector_theoryt::zero_extend(pointer_width - offset_bits)( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 The result type of pointer_offset_exprt
is usually signed. Therefore we should probably be using sign_extend
instead of zero_extend
. Note that the old SMT2 back end may may wrong in this case. Note also that the signed-ness is currently set in pointer_predicates.cpp
but we have no guarantees that these expressions will always have signed/unsigned results (unless we add appropriate invariants).
ℹ️ Negative offsets may occur in the the case of pointer offset overflows.
const auto converted_expr = converted.at(pointer_expr); | ||
const std::size_t pointer_width = type->get_width(); | ||
std::size_t offset_bits = pointer_width - config.bv_encoding.object_bits; | ||
if(offset_bits > pointer_width) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Are we actually truncating the result in this case? Might be worth adding a comment to that effect as this is slightly surprising and it might be worth just adding an invariant to avoid surprise truncation instead.
7b0b681
to
71ad410
Compare
71ad410
to
eaea1de
Compare
eaea1de
to
e5f91f2
Compare
|
||
// *q = p + 2; | ||
|
||
// __CPROVER_assert(__CPROVER_POINTER_OFFSET(p) != __CPROVER_POINTER_OFFSET(q), "expected failure"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ This assertion looks like it should pass once we have support for integer arithmetic. The assignment above will give q
an offset of 2 * sizeof(int)
and p will still have an offset of zero.
This PR adds the implementation (along with unit and regression tests)
for the conversion of
pointer_object_exprt
s andpointer_offset_exprt
s for the new SMT backend.(Because of some limitations for now in our support for arrays, pointer arithmetic,
pointer_offset_exprt
s are covered by unit tests only)