-
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
Assertion failed while type-casting #21073
Comments
Triage: still ICEs. Reproduces without using macros: struct Foo;
const OFFSET_OF_C: *const () = unsafe {
&*(0 as *const Foo)as *const _ as *const _
};
fn main() {
println!("offset of c {}" , OFFSET_OF_C as usize)
} $ rustc main.rs
main.rs:8:33: 8:44 error: internal compiler error: constant expression should not reach expr::trans_def
main.rs:8 println!("offset of c {}" , OFFSET_OF_C as usize) |
Here is another example: const TAG: &'static [u8] = b"ABCD";
macro_rules! tag(
($value:expr) => (unsafe {
let value: [u8; 4] = ::std::mem::transmute($value);
&vec![value[3], value[2], value[1], value[0]][..]
})
);
fn main() {
match tag!(42) {
TAG => println!("Yes."),
_ => println!("No."),
}
}
Regards, |
Simpler: const TAG: &'static [u8] = b"ABCD";
fn main() {
match &[][..] {
TAG => println!("Yes."),
_ => println!("No."),
}
} Seems like a missing slice-patterns check. |
The first two examples no longer ICE. The last two still do (SIGILL on stable, LLVM assertion failed on nightly). |
Reference rust-lang/rust#21073
Still ICEs on |
Is this undefined behavior? |
This ICE seems to be fixed on
I have a hunch that this is due to MIR being turned on, though I'm not sure. Please let me know if this still ICEs for you, but closing for now 🎊 |
While trying to write an offsetof that works in a constant expr, the compiler gets a low-level assertion failure.
With rust-nightly 201501120407
4bed1e8trusty:Via @edef1c
The text was updated successfully, but these errors were encountered: