Skip to content

Wrong codegen for generic foreign functions. #32364

Closed
@pravic

Description

@pravic

rustc 1.7.0 (a5d1e7a 2016-02-29) (32-bit GNU)
rustc 1.9.0-nightly (b12b4e4 2016-03-17) (32-bit MSVC)

#![allow(dead_code, unused_variables)]

extern "stdcall" fn foo_s(a: i32, _: i32, _: i32, _: i32, _: i32) {
    println!("foo_s<>{:?}", a);
}

extern "stdcall" fn bar_s<T>(a: i32, _: i32, _: i32, _: i32, _: i32) {
    println!("foo_s<T>{:?}", a);
}

struct FooHandler { me: i32, }

impl FooHandler {
    pub extern "stdcall" fn foo_s(a: i32, _: i32, _: i32, _: i32, _: i32) {
        println!("FooHandler::foo_s<>{:?}", a);
    }

    // this function does not following stdcall:
    pub extern "stdcall" fn bar_s_bug<T>(a: i32, _: i32, _: i32, _: i32, _: i32) {
        println!("FooHandler::bar_s<>{:?}", a);
    }
}

fn main() {
    let a = foo_s;
    let b = bar_s::<FooHandler>;

    let e = FooHandler::foo_s;
    let f = FooHandler::bar_s_bug::<FooHandler>;

    a(1, 0, 0, 0, 0);   // ok
    b(2, 0, 0, 0, 0);   // ok
    e(5, 0, 0, 0, 0);   // ok
    f(6, 0, 0, 0, 0);   // not stdcall.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions