Skip to content

Can't compare unsafe function pointers #718

Closed
@steveklabnik

Description

@steveklabnik

Issue by jdm
Monday Apr 07, 2014 at 20:28 GMT

For earlier discussion, see rust-lang/rust#13385

This issue was labelled with: in the Rust repository


type JSPropertyOp = extern "C" fn();
type JSPropertyOp2 = extern "C" unsafe fn();

extern fn foo() {
}

fn main() {
    let bar: JSPropertyOp = foo;
    if bar == foo {
    }

    let bar: JSPropertyOp2 = foo;
    if bar == foo {
    }
}

yields

[jdm@rosencrantz rust-mozjs]$ rustc /tmp/unsafe.rs 
/tmp/unsafe.rs:13:8: 13:18 error: binary operation `==` cannot be applied to type `extern "C" unsafe fn()`
/tmp/unsafe.rs:13     if bar == foo {
                         ^~~~~~~~~~
error: aborting due to previous error

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