Skip to content

__attribute__((overloadable)) function has wrong name #1350

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

Closed
bobbobbio opened this issue Jul 25, 2018 · 2 comments
Closed

__attribute__((overloadable)) function has wrong name #1350

bobbobbio opened this issue Jul 25, 2018 · 2 comments

Comments

@bobbobbio
Copy link

bobbobbio commented Jul 25, 2018

Input C Header

void
my_function(int a)
    __attribute__((overloadable));

void
my_function(const char *a);

Bindgen Invocation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen */

extern "C" {
    #[link_name = "\u{1}_Z11my_functioni"]
    pub fn my_function(a: ::std::os::raw::c_int);
}
extern "C" {
    pub fn my_function1(a: *const ::std::os::raw::c_char);
}

Expected Results

Normally bindgen gets things correct with the overloadable attribute, but in this specific case (when overloadable comes first followed by a function without it), the second function has the wrong name, and the binding doesn't work.

@emilio
Copy link
Contributor

emilio commented Nov 5, 2018

Yeah, we do if mangled_name == function_name { mangled_name = None } before doing the times_seen mangling, so I can see this breaking.

Should be pretty easy to fix though, thanks for the report!

@emilio emilio self-assigned this Nov 5, 2018
emilio added a commit to emilio/rust-bindgen that referenced this issue Nov 5, 2018
bors-servo pushed a commit that referenced this issue Nov 5, 2018
codegen: Make the mangling name check work in presence of attribute(overloadable).

Fixes #1350
@emilio
Copy link
Contributor

emilio commented Nov 5, 2018

Hmm, fwiw, that testcase in some compilers it complains hard:

tests/headers/issue-1350-attribute-overloadable.h:2:6: error: overloaded function 'my_function' must have the 'overloadable' attribute, err: true

emilio added a commit to emilio/rust-bindgen that referenced this issue Nov 5, 2018
bors-servo pushed a commit that referenced this issue Nov 6, 2018
codegen: Make the mangling name check work in presence of attribute(overloadable).

Fixes #1350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants