Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add a test for #107975 #127003
Add a test for #107975 #127003
Changes from all commits
2b08914
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 seems to assume that the difference between addresses of the two stack variables will never be larger than 3. This is not true with cg_clif where the difference is 16.
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.
Not really. It assumes that the difference is precisely 0 and non-0 at the same time. The test in question should ALWAYS panic in one place or another (even without the
assert_ne!(i, 0)
). But it doesn't, because some parts gets optimized as ifi
is 0, while others are optimized as if it is not.What I'm trying to say is that the length choice is arbitrary and that the test will fail no matter the value of
i
(be it 0, or 1, or 3, or 16, or whatever) as long as compiler does not make contradictory assumptions during optimization.It might actually even break if compiler still makes contradictory assumptions, but optimizes things differently.
The point of the test is to capture the current buggy behavior and demonstrate that it can lead to unsoundness in safe code.
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.
I thought the
//@ known-bug
would cause a//@ run-pass
test like this one to fail if it doesn't panic/crash, but I guess that is not the case. Because of that I thought a non-broke backend like cg_clif is expected to not panic anywhere on this test as opposed to be supposed to panic somewhere like actually happened with cg_clif.It would have been nice to mark this test as
//@ codegen-backend: llvm
, but no such test annotation is currently implemented unfortunately.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.
Could we use
let _: u8 = *r
here so we don't need the.stdout
file anymore. As the ui test tool doesn't care about the specific value of r.