Skip to content

Docs on std::mem::transmute incorrectly claim the types must have the same alignment #22032

Closed
@lilyball

Description

@lilyball

The std::mem::transmute docs says:

Both types must have the same size and alignment, and this guarantee is enforced at compile-time.

Experimentally, this function does not care about alignment:

#![feature(core)]
use std::simd::*;
use std::mem;

fn main() {
    let _ = unsafe { mem::transmute::<_,(u64,u64)>(u64x2(1,2)) }; // compiles just fine
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions