Skip to content

Include pointer offset in counterexample output #3135

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
Oct 31, 2018

Conversation

tautschnig
Copy link
Collaborator

While the bit-level pointer output would convey the information, the
human-readable expression previously did not consider non-zero offsets except
for null pointers.

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@kroening kroening changed the title git Include pointer offset in counterexample output Include pointer offset in counterexample output Oct 10, 2018
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Well this seems like an unpleasant omission. Are you sure that pointer_expr() is only used in output? If it is used elsewhere we might want to see if this fixes other things.

I guess if we really wanted to show off we could check if the base object was an array and turn it into &(a[i]). Would this be more human friendly than a + i ?

int A[2];
int *ip = &A[1];
uuu.structbb.intb = 1;
// assert(*ptr == 1);
Copy link
Member

Choose a reason for hiding this comment

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

Remove?

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Passed Diffblue compatibility checks (cbmc commit: 8652d9c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87494837

return typecast_exprt::conditional_cast(
plus_exprt(
base, from_integer(pointer.offset % *object_size, pointer_diff_type())),
type);
Copy link
Member

Choose a reason for hiding this comment

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

You probably meant pointer.offset / *object_size

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ooops - that clearly shows that my test case is not good enough. Thanks for catching that! I'll extend my test.

@tautschnig
Copy link
Collaborator Author

@martin-cs said:

[...] If it is used elsewhere we might want to see if this fixes other things.

I need to review #2161 as that has modifications in the same area of code.

@tautschnig tautschnig self-assigned this Oct 12, 2018
@tautschnig
Copy link
Collaborator Author

Marking do-not-merge as this needs to be built on top of the fixes in #2161.

While the bit-level pointer output would convey the information, the
human-readable expression previously did not consider non-zero offsets except
for null pointers.
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: e140d16).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89854653

@tautschnig tautschnig merged commit bcce848 into diffblue:develop Oct 31, 2018
@tautschnig tautschnig deleted the union-arithmetic branch October 31, 2018 18:54
@romainbrenguier romainbrenguier mentioned this pull request Nov 1, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants