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

wasm32 c++ constructors missing return values #1912

Closed
devsnek opened this issue Nov 3, 2020 · 3 comments
Closed

wasm32 c++ constructors missing return values #1912

devsnek opened this issue Nov 3, 2020 · 3 comments

Comments

@devsnek
Copy link

devsnek commented Nov 3, 2020

Input C/C++ Header

class X {
 public:
  X();
}

Bindgen Invocation

$ bindgen input.h -- -target wasm32-wasi -xc++ -fvisibility=default

Actual Results

extern "C" {
    #[link_name = "\u{1}_ZN1XC1Ev"]
    pub fn X_X(this: *mut X);
}

Expected Results

extern "C" {
    #[link_name = "\u{1}_ZN1XC1Ev"]
    pub fn X_X(this: *mut X) -> *mut X;
}

I went to try and fix this myself, and found this code, so there seems to be some larger bug:

let ret = if is_constructor && ctx.is_target_wasm32() {
// Constructors in Clang wasm32 target return a pointer to the object
// being constructed.
let void = Item::builtin_type(TypeKind::Void, false, ctx);
Item::builtin_type(TypeKind::Pointer(void), false, ctx)
} else {
Item::from_ty_or_ref(ty_ret_type, cursor, None, ctx)
};

@devsnek
Copy link
Author

devsnek commented Nov 3, 2020

Hmm I'm now noticing that this change was authored right after 0.55.1 was cut. I guess we just have to wait for the next version?

@emilio
Copy link
Contributor

emilio commented Nov 13, 2020

Ah, I can publish a release, sorry. Generally if you need a release, feel free to ping.

@emilio
Copy link
Contributor

emilio commented Nov 13, 2020

Let's close this since this is fixed. I'll publish a release in the next few days (#1846 should be pretty close to landing).

@emilio emilio closed this as completed Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants