-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ctfe validation on unaligned references does not mention expected / provided alignment #58617
Comments
I think all we need is rust/src/librustc_mir/interpret/validity.rs Lines 360 to 361 in 0e25a68
AlignmentCheckFailed and add their information to the validation failure string.
|
I'd like to do it. |
It's all your's, let me know if you have any questions |
Hmm both of these snippets seem to compile in the playground (when unused use removed). |
Yes the examples compile fine. The issue is triggered by running them under miri. |
You can probably repro the same thing in rustc with const eval by making the final value be such an invalid reference |
Jup, here's a repro (that you can use as a regression test, too): #![feature(const_transmute)]
const FOO: &u64 = unsafe {
use std::mem::transmute;
let a = &0_u8;
let b = a as *const u8 as *const u64;
transmute(b)
}; |
Note, that clippy does emit an error:
|
@hellow554 thanks, i've reported the issue there tiL rust-lang/rust-clippy#3797 |
Add expected/provided byte alignments to validation error message Fixes rust-lang#58617
Add expected/provided byte alignments to validation error message Fixes rust-lang#58617
This code (playground):
errors under miri with
This snippet, however (playground):
errors with
It would be great if this error about the validity of references would also state that "alignment 1, but alignment 8 is required" or similar.
cc @oli-obk @RalfJung
The text was updated successfully, but these errors were encountered: