Skip to content

cast_ptr_alignment should include a note with the alignment of types involved #3797

Closed
@gnzlbg

Description

@gnzlbg

Playground:

fn main() {
    unsafe {
        use std::mem::transmute;
        let a = 0_u8;
        let b = &a as *const u8 as *const u64;
        //let _c: &u64 = transmute(b);
        let _d = *b;
    }
}

makes cast_ptr_alignment report

error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u64`)

We might want to add a note stating what the alignment of u8 and of u64 is.

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