Skip to content
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

Update raw_eq documentation and tests #1091

Merged
merged 6 commits into from
Apr 23, 2022

Conversation

adpaco-aws
Copy link
Contributor

Description of changes:

First, I'm not clear on why I wrote that layout comparison was a requirement. raw_eq is implemented as memcmp and the documentation does not mention layout anywhere: https://doc.rust-lang.org/core/intrinsics/fn.raw_eq.html
What it does mention is that uninitialized memory in any of the arguments is undefined behavior.

This PR updates the notes on Rust feature support to mention uninitialized memory, which we had to do anyways because of #920. It also updates the comment on raw_eq and adds two new tests for checking the behavior with uninitialized data.

I think there is nothing else to be done with raw_eq until we can poison memory (see #920).

Resolved issues:

Resolves #347
Part of #727

Testing:

  • How is this change tested? Adds two tests

  • Is this a refactor change? No

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco-aws adpaco-aws requested a review from a team as a code owner April 22, 2022 14:45
docs/src/rust-feature-support.md Outdated Show resolved Hide resolved
let uninit_arr: [u8; 8] = unsafe { MaybeUninit::uninit().assume_init() };

let arr_are_eq = unsafe { raw_eq(&zeroed_arr, &uninit_arr) };
assert!(!arr_are_eq);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this second test is necessary?

Copy link
Contributor Author

@adpaco-aws adpaco-aws Apr 22, 2022

Choose a reason for hiding this comment

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

It's expressing that raw_eq is also true in at least one trace, thus complementing the other test case.

@adpaco-aws adpaco-aws merged commit 9a2ef1d into model-checking:main Apr 23, 2022
@adpaco-aws adpaco-aws mentioned this pull request Apr 23, 2022
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Update `raw_eq` documentation

* Updates test and adds two more

* Comment from review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend handling of raw_eq intrinsic
2 participants