-
Notifications
You must be signed in to change notification settings - Fork 97
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
Basic tests for size_of_val
and min_alig_of_val
#1101
Basic tests for size_of_val
and min_alig_of_val
#1101
Conversation
enum MyEnum { | ||
Variant, | ||
} | ||
|
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.
Might be interesting to add a repr(C)
struct which would require padding and make sure we get this right
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.
Added a repr(C)
struct and assertions based on it. As far as I can tell, it's working as expected:
- Size takes into account padding
- Alignment is the max alignment for each field
But let me know if you want to test specific cases and I will add them.
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that we get the expected results for the `min_align_of_val` intrinsic | ||
// with common data types |
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.
Is this architecture specific, of do these min aligns come from the rust spec?
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.
My understanding is that min_align_of_val
depends on min_global_align
, which is an architecture option.
Please note that in #1054 we added checks to ensure that min_global_align
is unspecified or equal to 1, otherwise Kani will stop there.
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.
Can you add a comment that the tests here assume x86, otherwise good to go.
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.
Approved modulo one comment
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that we get the expected results for the `min_align_of_val` intrinsic | ||
// with common data types |
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.
Can you add a comment that the tests here assume x86, otherwise good to go.
* Basic tests for `size_of_val` and `min_alig_of_val` * Fix format * Add cases for `repr(C)` struct * Add note
Description of changes:
Adds two tests for
size_of_val
andmin_align_of_val
.@celinval added tests for dynamically-sized types in #1089 , these ones just complement them by testing basic types.
Resolved issues:
Part of #727
Call-outs:
Testing:
How is this change tested? Adds two tests.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.