-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Different behavior when changing opt-level
#126866
Comments
The @rustbot label -needs-triage -C-bug +C-discussion |
As a fix, I would suggest having |
If writing unsafe code, you may want to use Miri Output
|
Ah thanks for the explanation and tips! I will check out miri! |
Casting a T pointer to a usize and misalign it causes undefined behavior. See rust-lang/rust#126866
I tried this code:
I expected to see this happen:
Regardless of
opt-level
in Cargo.toml, the assertion should succeed since the deref impl would undo the pointer tag.Instead, this happened:
With
opt-level = 0
, I see the expected behavior: assertion succeeds. But withopt-level = 1
or above, the assertion fails.Meta
Backtrace
The text was updated successfully, but these errors were encountered: