-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
transmute size check is wrong for overaligned newtype #155412
Copy link
Copy link
Open
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-layoutArea: Memory layout of typesArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-layoutArea: Memory layout of typesArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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)