Skip to content

It should be unsafe to cast an extern function to a function pointer #55226

Closed
@matthewjasper

Description

@matthewjasper

The following code gives a linker error, which arguably shouldn't happen in safe code.

extern {
    fn doesnt_exist();
}
fn main() {
    println!("{:p}", doesnt_exist as unsafe extern "C" fn());
}

Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions