Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong codegen for generic foreign functions. #32364

Closed
pravic opened this issue Mar 19, 2016 · 3 comments
Closed

Wrong codegen for generic foreign functions. #32364

pravic opened this issue Mar 19, 2016 · 3 comments
Labels
A-FFI Area: Foreign function interface (FFI) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@pravic
Copy link
Contributor

pravic commented Mar 19, 2016

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.
}
@eddyb
Copy link
Member

eddyb commented Mar 24, 2016

This was fixed by #32080, impl methods' ABIs were previously completely ignored.

@eddyb eddyb added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. A-FFI Area: Foreign function interface (FFI) labels Mar 24, 2016
@pravic
Copy link
Contributor Author

pravic commented Mar 24, 2016

Yes, rustc 1.9.0-nightly (21922e1 2016-03-21) (32-bit MSVC) is working fine.
Thanks.

@pravic pravic closed this as completed Mar 24, 2016
@eddyb
Copy link
Member

eddyb commented Mar 24, 2016

I'd like this open to make sure a test ends up being written.

@eddyb eddyb reopened this Mar 24, 2016
dsprenkels added a commit to dsprenkels/rust that referenced this issue Jun 12, 2016
bors added a commit that referenced this issue Jun 13, 2016
Add regression test for #32364

This PR adds a regression test for #32364.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-FFI Area: Foreign function interface (FFI) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

2 participants