Skip to content

better precision of value_set on unions #2851

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
Sep 23, 2018
Merged

better precision of value_set on unions #2851

merged 1 commit into from
Sep 23, 2018

Conversation

kroening
Copy link
Member

This is motivated by the linked list implementation in FreeRTOS.

@tautschnig
Copy link
Collaborator

What is the relationship between this one and #2854?

@kroening
Copy link
Member Author

Relationship to #2854: They both concern unions, but appear to be different.

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.

This PR failed Diffblue compatibility checks (cbmc commit: 0c8ef66).
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

if(byte_extract_expr.offset().is_zero())
{
const union_typet &union_type = to_union_type(op_type);
const typet subtype = union_type.component_type(component_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Const ref?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Only once #2987 has been merged.


union U
{
struct List my_list;
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment inline about whether the single-item union is important or not, since that's pretty unusual afaik


struct List
{
unsigned something;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused in the test case? Is it important that neither struct member is at zero offset? If so comment inline about why

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's crucial to make this pass/fail. I have added both an inline comment and information to the commit message.


struct list_item
{
struct list_item *previous;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a single member struct instead of simply inlining this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could have more members, just don't need more to demonstrate the problem/the fix.

}

assign(lhs_member, rhs_member, ns, false, add_to_sets);
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm reading this right the ID_unknown case used to be silently ignored? I suspect this increase in pessimism / improvement in soundness will have side effects, consider doing that as a separate PR since that seems orthogonal to simplifying unions?

@tautschnig
Copy link
Collaborator

I would like to wait for #2987 to be merged before doing further work here.

…implifier

Previously, only the case of struct members with offset zero was handled with
sufficient precision. Using structs inside unions where a member of non-zero
offset is accessed is now handled precisely.
@tautschnig
Copy link
Collaborator

@smowton All comments addressed.

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.

This PR failed Diffblue compatibility checks (cbmc commit: 61ffc48).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85635549
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

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: f2f2c60).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85636056

@kroening
Copy link
Member Author

@tautschnig Indeed much better to have this in the simplifier.

@kroening kroening merged commit 20f8b96 into develop Sep 23, 2018
@kroening kroening deleted the value_set_unions branch September 23, 2018 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants