Skip to content

Why use 1usize instead of 0usize in unreachable? #158

Closed
@playXE

Description

@playXE

Why use 1usize instead of 0usize there :

#[inline]
pub unsafe fn unreachable() -> ! {
    enum Void {}
    let x: &Void = mem::transmute(1usize);
    match *x {}
}

If this function should trigger UB?

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