I tried this code:
use std::mem::transmute;
#[repr(align(16))]
struct Wrap<T>(T);
fn foo<T: ?Sized>(x: Wrap<*const T>) -> *const T {
unsafe { transmute(x) }
}
fn main() {
foo(Wrap(std::ptr::null::<i32>()));
println!("done");
}
The above code shouldn't compile, since Wrap<*const i32> and *const i32 don't have the same size, and transmute is supposed to check the sizes of the two types to be equal at compile time.
Instead, the code compiles and causes a segmentation fault at run time.
The generated assembly is particularly nonsensical:
example::foo::<i32>:
mov byte ptr [rax], 1
ret
Possibly related to #101084. cc @RalfJung @oli-obk
Meta
Reproducible on the playground with version 1.97.0-nightly (2026-04-15 e8e4541ff19649d95afa)
I tried this code:
The above code shouldn't compile, since
Wrap<*const i32>and*const i32don't have the same size, andtransmuteis supposed to check the sizes of the two types to be equal at compile time.Instead, the code compiles and causes a segmentation fault at run time.
The generated assembly is particularly nonsensical:
Possibly related to #101084. cc @RalfJung @oli-obk
Meta
Reproducible on the playground with version
1.97.0-nightly (2026-04-15 e8e4541ff19649d95afa)