Skip to content

Compiler segfaults when casting 0 as fat pointer #30577

Closed
@apoelstra

Description

@apoelstra

This is really nasty code, but simias on IRC was trying to get a null fat-pointer constant and this was one idea I tried.

type WillRobinson = u8;
trait Danger {}
impl Danger for WillRobinson {}

static mut danger: *mut Danger = (0 as *mut WillRobinson) as *mut Danger;

fn main() {}

This causes a segfault in rustc during compilation. The "unused variable" warning displays. I don't have a rustc with debug symbols, so not attaching backtrace, sorry.

Possibly related to #13520

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions